Address Book

class O365.address_book.AddressBook(*, parent=None, con=None, **kwargs)[source]

Bases: ContactFolder

A class representing an address book

__init__(*, parent=None, con=None, **kwargs)[source]

Create a contact folder component

Parameters:
  • parent (BaseContactFolder or Account) – parent folder/account for this folder

  • con (Connection) – connection to use if no parent specified

  • protocol (Protocol) – protocol to use if no parent specified (kwargs)

  • main_resource (str) – use this resource instead of parent resource (kwargs)

class O365.address_book.BaseContactFolder(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

Base Contact Folder Grouping Functionality

__init__(*, parent=None, con=None, **kwargs)[source]

Create a contact folder component

Parameters:
  • parent (BaseContactFolder or Account) – parent folder/account for this folder

  • con (Connection) – connection to use if no parent specified

  • protocol (Protocol) – protocol to use if no parent specified (kwargs)

  • main_resource (str) – use this resource instead of parent resource (kwargs)

get_contact_by_email(email)[source]

Returns a Contact by it’s email

Parameters:

email – email to get contact for

Returns:

Contact for specified email

Return type:

Contact

get_contacts(limit=100, *, query=None, order_by=None, batch=None)[source]

Gets a list of contacts from this address book

To use query an order_by check the OData specification here: http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/ part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions -complete.html

Parameters:
  • limit (int or None) – max no. of contacts to get. Over 999 uses batch.

  • query (Query or str) – applies a OData filter to the request

  • order_by (Query or str) – orders the result set based on this condition

  • batch (int) – batch size, retrieves items in batches allowing to retrieve more items than the limit.

Returns:

list of contacts

Return type:

list[Contact] or Pagination

folder_id

Unique identifier of the contact folder.

   Type: str

name

The folder’s display name.

   Type: str

parent_id

The ID of the folder’s parent folder.

   Type: str

root

Indicates if this is the root folder.

   Type: bool

class O365.address_book.Contact(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent, AttachableMixin

Contact manages lists of events on associated contact on office365.

__init__(*, parent=None, con=None, **kwargs)[source]

Create a contact API component

Parameters:
  • parent (Account) – parent account for this folder

  • con (Connection) – connection to use if no parent specified

  • protocol (Protocol) – protocol to use if no parent specified (kwargs)

  • main_resource (str) – use this resource instead of parent resource (kwargs)

delete()[source]

Deletes this contact

Returns:

Success or Failure

Return type:

bool

Raises:

RuntimeError – if contact is not yet saved to cloud

get_profile_photo(size=None)[source]

Returns this contact profile photo

Parameters:

size (str) – 48x48, 64x64, 96x96, 120x120, 240x240, 360x360, 432x432, 504x504, and 648x648

new_message(recipient=None, *, recipient_type=RecipientType.TO)[source]

This method returns a new draft Message instance with contacts first email as a recipient

Parameters:
  • recipient (Recipient) – a Recipient instance where to send this message. If None first email of this contact will be used

  • recipient_type (RecipientType) – section to add recipient into

Returns:

newly created message

Return type:

Message or None

save()[source]

Saves this contact to the cloud (create or update existing one based on what values have changed)

Returns:

Saved or Not

Return type:

bool

to_api_data(restrict_keys=None)[source]

Returns a dictionary in cloud format

Parameters:

restrict_keys – a set of keys to restrict the returned data to.

update_profile_photo(photo)[source]

Updates this contact profile photo :param bytes photo: the photo data in bytes

property business_address

Business Address

Getter:

Get the address of contact

Setter:

Update the address

Type:

dict

property business_phones

Business Contact numbers

Getter:

Get the contact numbers of contact

Setter:

Update the contact numbers

Type:

list[str]

property categories

Assigned Categories

Getter:

Get the categories

Setter:

Update the categories

Type:

list[str]

property company_name

Name of the company

Getter:

Get the company name of contact

Setter:

Update the company name

Type:

str

property created

Created Time

Return type:

datetime

property department

Department

Getter:

Get the department of contact

Setter:

Update the department

Type:

str

property display_name

Display Name

Getter:

Get the display name of the contact

Setter:

Update the display name

Type:

str

property emails

List of email ids of the Contact

Return type:

Recipients

property fileAs

File As

Getter:

Get the fileAs of the contact

Setter:

Update the fileAs

Type:

str

property folder_id

ID of the containing folder

Return type:

str

property full_name

Full Name (Name + Surname)

Return type:

str

property home_address

Home Address

Getter:

Get the address of contact

Setter:

Update the address

Type:

dict

property home_phones

Home Contact numbers

Getter:

Get the contact numbers of contact

Setter:

Update the contact numbers

Type:

list[str]

property job_title

Job Title

Getter:

Get the job title of contact

Setter:

Update the job title

Type:

str

property main_email

Primary(First) email id of the Contact

Return type:

str

property mobile_phone

Personal Contact numbers

Getter:

Get the contact numbers of contact

Setter:

Update the contact numbers

Type:

list[str]

property modified

Last Modified Time

Return type:

datetime

property name

First Name

Getter:

Get the name of the contact

Setter:

Update the name

Type:

str

object_id

The contact’s unique identifier.

   Type: str

property office_location

Office Location

Getter:

Get the office location of contact

Setter:

Update the office location

Type:

str

property other_address

Other Address

Getter:

Get the address of contact

Setter:

Update the address

Type:

dict

property personal_notes
property preferred_language

Preferred Language

Getter:

Get the language of contact

Setter:

Update the language

Type:

str

property surname

Surname of Contact

Getter:

Get the surname of the contact

Setter:

Update the surname

Type:

str

property title

Title (Mr., Ms., etc..)

Getter:

Get the title of the contact

Setter:

Update the title

Type:

str

class O365.address_book.ContactFolder(*, parent=None, con=None, **kwargs)[source]

Bases: BaseContactFolder

A Contact Folder representation

create_child_folder(folder_name)[source]

Creates a new child folder

Parameters:

folder_name (str) – name of the new folder to create

Returns:

newly created folder

Return type:

ContactFolder or None

delete()[source]

Deletes this folder

Returns:

Deleted or Not

Return type:

bool

get_folder(folder_id=None, folder_name=None)[source]

Returns a Contact Folder by it’s id or child folders by name

Parameters:
  • folder_id – the folder_id to be retrieved. Can be any folder Id (child or not)

  • folder_name – the folder name to be retrieved. Must be a child of this folder

Returns:

a single contact folder

Return type:

ContactFolder

get_folders(limit=None, *, query=None, order_by=None)[source]

Returns a list of child folders

Parameters:
  • limit (int) – max no. of folders to get. Over 999 uses batch.

  • query (Query or str) – applies a OData filter to the request

  • order_by (Query or str) – orders the result set based on this condition

Returns:

list of folders

Return type:

list[ContactFolder]

move_folder(to_folder)[source]

Change this folder name

Parameters:

to_folder (str or ContactFolder) – folder_id/ContactFolder to move into

Returns:

Moved or Not

Return type:

bool

new_contact()[source]

Creates a new contact to be saved into it’s parent folder

Returns:

newly created contact

Return type:

Contact

new_message(recipient_type=RecipientType.TO, *, query=None)[source]

This method returns a new draft Message instance with all the contacts first email as a recipient

Parameters:
  • recipient_type (RecipientType) – section to add recipient into

  • query (Query or str) – applies a OData filter to the request

Returns:

newly created message

Return type:

Message or None

update_folder_name(name)[source]

Change this folder name

Parameters:

name (str) – new name to change to

Returns:

Updated or Not

Return type:

bool