Skip to content

botcity.plugins.gmail.plugin.BotGmailPlugin

__init__(self, credentials_file_path, user_email) special

BotGmailPlugin.

Parameters:

Name Type Description Default
credentials_file_path str

The path of the credentials json file obtained at Google Cloud Platform.

required
user_email str

The email used to create the credentials.

required

add_labels_to_message(self, msg, default_labels=None, customized_labels=None)

Add default and custom labels to the message.

Parameters:

Name Type Description Default
msg BotGmailMessage

The message that will receive the labels.

required
default_labels List[GmailDefaultLabels]

The list with the names of the labels defined in the GmailDefaultLabels class.

None
customized_labels List[str]

The list with the names of the labels created by user.

None

create_new_label(self, label_name)

Create a new label on email.

Parameters:

Name Type Description Default
label_name str

The name of the label to be created.

required

delete(self, msg)

Move a email message to trash.

Parameters:

Name Type Description Default
msg BotGmailMessage

The message to be deleted.

required

delete_label(self, label_id)

Move a label to trash.

Parameters:

Name Type Description Default
label_id str

Label id to delete.

required

download_attachments(self, msg, download_folder_path)

Download attachments from a given email message.

Parameters:

Name Type Description Default
msg BotGmailMessage

The message that contains the attachments.

required
download_folder_path str

The path of the folder where the files will be saved.

required

forward(self, msg, to_addrs, cc_addrs=None, bcc_addrs=None, include_attachments=True, use_html=False)

Forward a received email message.

Parameters:

Name Type Description Default
msg BotGmailMessage

The message to forward.

required
to_addrs List[str]

The list of email addresses that will receive the message.

required
cc_addrs List[str]

The list of email addresses that will receive the message as CC.

None
bcc_addrs List[str]

The list of email addresses that will receive the message as BCC.

None
include_attachments boolean

Include attachments from the original message.

True
use_html bool

The boolean value when you want to use body in html format.

False

get_label(self, by, value)

Search label by name.

Parameters:

Name Type Description Default
by SearchBy

Enum to search by

required
value str

Value to search

required

get_mail_labels(self)

Get all valid labels from email.

Returns:

Type Description
List[dict]

The list containing the name and id of each label found as a dictionary.

mark_as_read(self, msg)

Mark a email message as read.

Parameters:

Name Type Description Default
msg BotGmailMessage

The message to be marked.

required

mark_as_unread(self, msg)

Mark a email message as unread.

Parameters:

Name Type Description Default
msg BotGmailMessage

The message to be marked.

required

remove_labels_from_message(self, msg, default_labels=None, customized_labels=None)

Remove default and custom labels from the message.

Parameters:

Name Type Description Default
msg BotGmailMessage

The message that will have the labels removed.

required
default_labels List[GmailDefaultLabels]

The list with the names of the labels defined in the GmailDefaultLabels class.

None
customized_labels List[str]

The list with the names of the labels created by user.

None

reply(self, msg, text_content, attachments=None, to_addrs=None, cc_addrs=None, bcc_addrs=None, use_html=False)

Reply a received email message.

Parameters:

Name Type Description Default
msg BotGmailMessage

The message to reply.

required
text_content str

The content of the email body.

required
attachments List[str]

The list with the paths of the files that will be sent as attachments.

None
to_addrs List[str]

The list of email addresses that will receive the message.

None
cc_addrs List[str]

The list of email addresses that will receive the message as CC.

None
bcc_addrs List[str]

The list of email addresses that will receive the message as BCC.

None
use_html bool

The boolean value when you want to use body in html format.

False

reply_to_all(self, msg, text_content, attachments=None, use_html=False)

Reply to all email addresses included in the original message.

Parameters:

Name Type Description Default
msg BotGmailMessage

The message to reply.

required
text_content str

The content of the email body.

required
attachments List[str]

The list with the paths of the files that will be sent as attachments.

None
use_html bool

The boolean value when you want to use body in html format.

False

search_messages(self, criteria=None, default_labels=None, customized_labels=None, mark_read=False, timeout=0)

Search for messages based on criteria and labels.

See how to use and more details about searches

To see the labels that are available in the email, use get_mail_labels()

See more details about messages labels

Parameters:

Name Type Description Default
criteria str

The criteria that will be used as a message filter.

None
default_labels List[GmailDefaultLabels]

The list with the names of the labels defined in the GmailDefaultLabels class, which will be considered in the message filter.

None
customized_labels List[str]

The list with the names of the labels created by user which will be considered in the message filter.

None
mark_read boolean

Whether the email should be marked as read. Defaults to False.

False
timeout int

Wait for a new message until this timeout. Defaults to 0 seconds (don't wait for new messages).

0

send_message(self, subject, text_content, to_addrs, cc_addrs=None, bcc_addrs=None, attachments=None, use_html=False)

Send a new email message.

Parameters:

Name Type Description Default
subject str

The subject of the email.

required
text_content str

The content of the email body.

required
to_addrs List[str]

The list of email addresses that will receive the message.

required
cc_addrs List[str]

The list of email addresses that will receive the message as CC.

None
bcc_addrs List[str]

The list of email addresses that will receive the message as BCC.

None
attachments List[str]

The list with the paths of the files that will be sent as attachments.

None
use_html bool

The boolean value when you want to use body in html format.

False