Address Book

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

Bases: O365.address_book.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: O365.utils.utils.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)

contact_constructor

alias of Contact

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

message_constructor

alias of O365.message.Message

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

Bases: O365.utils.utils.ApiComponent, O365.utils.attachment.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)

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

delete()[source]

Deletes this contact

Returns

Success or Failure

Return type

bool

Raises

RuntimeError – if contact is not yet saved to cloud

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 folder_id

ID of the folder

Return type

str

property full_name

Full Name (Name + Surname)

Return type

str

get_profile_photo(size=None)[source]

Returns this contact profile photo :param str size: 48x48, 64x64, 96x96, 120x120, 240x240,

360x360, 432x432, 504x504, and 648x648

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

message_constructor

alias of O365.message.Message

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

new_message(recipient=None, *, recipient_type=<RecipientType.TO: '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

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

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

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

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

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

Bases: O365.address_book.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: '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