fusetools.gsuite_tools.GMail¶
-
class
fusetools.gsuite_tools.GMail[source]¶ Bases:
objectFunctions for interacting with GMail.
Methods
Creates an authenticated service object for GMail.
Creates a GMail authenticated credentials object.
Downloads email attachments for a given emails.
Returns a Pandas DataFrame of received email details.
- param service
Sends an email via GMail.
-
classmethod
create_service(cred_path, token_path=None, working_dir=None)[source]¶ Creates an authenticated service object for GMail.
- Parameters
cred_path – Path to Google credentials object.
token_path – Path of authentication token.
working_dir – Path of working directory to store token if token path not specified.
- Returns
Authenticated service object for GMail
-
classmethod
create_service_serv_acct(member_acct_email, token_path)[source]¶ Creates a GMail authenticated credentials object.
- Parameters
member_acct_email – GSuite service acct email address.
token_path – Path to GSuite authentication token.
- Returns
Return GMail authenticated credentials object.
-
classmethod
download_email_attachment(service, msg_id, sav_dir=False, user_id='me', save_memory=False, req_limit=1)[source]¶ Downloads email attachments for a given emails.
- Parameters
service – Authenticated service object for GMail.
msg_id – ID of message to download attachments for.
sav_dir – Directory to save an attachment into.
user_id – User ID to pull emails for, default=”me”.
- Returns
Downloaded email attachments.
-
classmethod
get_emails(service, label_ids=False, custom_tree_branch_list=False, user_id='me', req_limit=1)[source]¶ Returns a Pandas DataFrame of received email details.
- Parameters
service – Authenticated service object for GMail.
user_id – User ID to pull emails for, default=”me”
label_ids – GMail label IDs to pull messages for, default=”INBOX”
custom_tree_branch_list – List of branch elements to navigate HTML body data (ex: [0,1,0])
- Returns
Pandas DataFrame of received email details.
-
classmethod
get_mailbox_labels(service, user_id='me', req_limit=1)[source]¶ - Parameters
service –
user_id –
- Returns
-
classmethod
send_email(service, to, sender, subject, message_text, attachments=False, attachments_bytes=False, attachment_types=False, attachment_names=False, message_is_html=False, req_limit=1)[source]¶ Sends an email via GMail.
- Parameters
service – Authenticated service object for GMail.
to – Target email address.
sender – Sender email address.
subject – Subject for email.
message_text – Message body text.
attachments – List of message attachments.
message_is_html – Whether or not message_text is in HTML format.
- Returns
Sent message.