GMail

implement api to access gmail

class pysuite.gmail.GMail(service: googleapiclient.discovery.Resource)[source]

Bases: object

A class containing methods to interact with Gmail APIs such as sending emails

Parameters

service – an authorized GMail service client.

compose(sender: str, to: Union[str, list], cc: Optional[Union[str, list]] = None, bcc: Optional[Union[str, list]] = None, body: Optional[str] = None, subject: Optional[str] = None, local_files: Optional[Union[pathlib.PosixPath, str]] = None, gdrive_ids: Optional[List[str]] = None, user_id: Optional[str] = None, is_html: bool = True) → dict[source]

Compose an email and send through gmail api.

Parameters
  • sender – email of the sender

  • to – a string of one email or list of emails of the targets

  • cc – a string of one email or list of emails of cc’ed targets

  • bcc – a string of one email or list of emails of bcc’ed targets

  • body – main content in email body.

  • subject – subject line

  • local_files – list of files to be attached in the email

  • gdrive_ids – list of gdrive ids attached in the email

  • user_id – identification of user. If None, it sender email will be used.

  • is_html – whether body is send in html format. If False, plain text format will be used.

Returns

a dictionary of response. containing ‘id’ (id of the email). ‘threadId’ (id of the email thread) and ‘labelIds’ (list of label ids)