Attachment

class O365.utils.attachment.AttachableMixin(attachment_name_property=None, attachment_type=None)[source]

Bases: object

__init__(attachment_name_property=None, attachment_type=None)[source]

Defines the functionality for an object to be attachable. Any object that inherits from this class will be attachable (if the underlying api allows that)

property attachment_name

Name of the attachment

Getter

get attachment name

Setter

set new name for the attachment

Type

str

property attachment_type

Type of attachment

Return type

str

to_api_data()[source]

Returns a dict to communicate with the server

Return type

dict

class O365.utils.attachment.BaseAttachment(attachment=None, *, parent=None, **kwargs)[source]

Bases: O365.utils.utils.ApiComponent

BaseAttachment class is the base object for dealing with attachments

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

Creates a new attachment, optionally from existing cloud data

Parameters
  • attachment (dict or str or Path or list[str] or AttachableMixin) – attachment data (dict = cloud data, other = user data)

  • parent (BaseAttachments) – the parent Attachments

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

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

attach(api_object, on_cloud=False)[source]

Attach this attachment to an existing api_object. This BaseAttachment object must be an orphan BaseAttachment created for the sole purpose of attach it to something and therefore run this method.

Parameters
  • api_object – object to attach to

  • on_cloud – if the attachment is on cloud or not

Returns

Success / Failure

Return type

bool

save(location=None, custom_name=None)[source]

Save the attachment locally to disk

Parameters
  • location (str) – path string to where the file is to be saved.

  • custom_name (str) – a custom name to be saved as

Returns

Success / Failure

Return type

bool

to_api_data()[source]

Returns a dict to communicate with the server

Return type

dict

class O365.utils.attachment.BaseAttachments(parent, attachments=None)[source]

Bases: O365.utils.utils.ApiComponent

A Collection of BaseAttachments

__init__(parent, attachments=None)[source]

Attachments must be a list of path strings or dictionary elements

Parameters
  • parent (Account) – parent object

  • attachments (list[str] or list[Path] or str or Path or dict) – list of attachments

add(attachments)[source]

Add more attachments

Parameters

attachments (list[str] or list[Path] or str or Path or dict) – list of attachments

clear()[source]

Clear the attachments

download_attachments()[source]

Downloads this message attachments into memory. Need a call to ‘attachment.save’ to save them on disk.

Returns

Success / Failure

Return type

bool

remove(attachments)[source]

Remove the specified attachments

Parameters

attachments (list[str] or list[Path] or str or Path or dict) – list of attachments

to_api_data()[source]

Returns a dict to communicate with the server

Return type

dict