Add Gmail Labels

Add GMail labels to messages matching criterion and if given, source folder

Arguments

Argument Type Default value Description
labelsnull
criterionnull
source_folderstrNone

Add GMail labels to messages matching criterion and if given, source folder

param labels:comma separated list of labels to add
param criterion:
 label messages matching criterion
param source_folder:
 look for messages in this folder, default all folders
return:status of the operation

Examples

*** Tasks ***
Add Gmail Labels  customer1   SUBJECT "order confirmation"
Add Gmail Labels  wip         SUBJECT "order confirmation"   customerfolder

Authorize

Authorize user to SMTP and IMAP servers.

Arguments

Argument Type Default value Description
accountstr, NoneNone
passwordstr, NoneNone
smtp_serverstr, NoneNone
imap_serverstr, NoneNone
smtp_portint, NoneNone
imap_portint, NoneNone
param account:user account as string, defaults to None
param password:user password as string, defaults to None
param smtp_server:
 SMTP server address, defaults to None
param imap_server:
 IMAP server address, defaults to None
param smtp_port:
 SMTP server port, defaults to None (587 for SMTP)
param imap_port:
 IMAP server port, defaults to None

Will use separately set credentials or those given in keyword call.

Examples

*** Tasks ***
Authorize    ${username}   ${password}  smtp_server=smtp.gmail.com  smtp_port=587

Authorize Imap

Authorize to IMAP server.

Arguments

Argument Type Default value Description
accountstr, NoneNone
passwordstr, NoneNone
imap_serverstr, NoneNone
imap_portint, NoneNone
param account:IMAP account name, defaults to None
param password:IMAP account password, defaults to None
param imap_server:
 IMAP server address, defaults to None
param imap_port:
 IMAP server port, defaults to None

Can be called without giving any parameters if library has been initialized with necessary information and/or keyword Set Credentials has been called.

Examples

*** Tasks ***
Authorize IMAP    ${username}   ${password}  imap.gmail.com  993

Authorize Smtp

Authorize to SMTP server.

Arguments

Argument Type Default value Description
accountstr, NoneNone
passwordstr, NoneNone
smtp_serverstr, NoneNone
smtp_portint, NoneNone
param account:SMTP account name, defaults to None
param password:SMTP account password, defaults to None
param smtp_server:
 SMTP server address, defaults to None
param smtp_port:
 SMTP server port, defaults to None (587 for SMTP)

Can be called without giving any parameters if library has been initialized with necessary information and/or keyword Set Credentials has been called.

Examples

*** Tasks ***
Authorize SMTP    ${username}   ${password}  smtp.gmail.com  587

Create Folder

Create email folder

Arguments

Argument Type Default value Description
folder_namestrNone
param folder_name:
 name for the new folder
return:True if operation was successful, False if not

Examples

*** Tasks ***
Create Folder   filtered

Delete Folder

Delete email folder

Arguments

Argument Type Default value Description
folder_namestrNone
param folder_name:
 current folder name
return:True if operation was successful, False if not

Examples

*** Tasks ***
Delete Folder   filtered

Delete Message

Delete single message from server based on criterion.

Arguments

Argument Type Default value Description
criterionstr
param criterion:
 filter messages based on this, defaults to ""
return:True if success, False if not

If criterion does not return exactly 1 message then delete is not done.

Examples

*** Tasks ***
Delete Message  SUBJECT "Greetings RPA developer"

Delete Messages

Delete messages from server based on criterion.

Arguments

Argument Type Default value Description
criterionstr
limitintNone
param criterion:
 filter messages based on this, defaults to ""
param limit:maximum number of message to delete
return:True if success, False if not

Examples

*** Tasks ***
Delete Messages  SUBJECT Greetings

Do Message Actions

Do actions to messages matching criterion and if given, source folder

Arguments

Argument Type Default value Description
criterionstr
actionslistNone
source_folderstrNone
target_folderstrNone
labelsstrNone
limitintNone
overwriteboolFalse

Do actions to messages matching criterion and if given, source folder

Actions can be:

  • msg_copy
  • msg_delete
  • msg_flag
  • msg_unflag
  • msg_read
  • msg_unread
  • msg_save
  • msg_attachment_save
  • glabel_add
  • glabel_remove

Result object contains following attributes:

  • actions_done, number of messages on which action was performed
  • message_count, number of messages matching criterion
  • ids, message ids matching criterion
  • uids, dictionary of message uids and message content
param criterion:
 perform actions on messages matching this
param actions:list of actions to perform on matching messages
param source_folder:
 look for messages in this folder, default all folders
param target_folder:
 can be file path or email folder (for example action: msg_copy)
param labels:comma separated list of labels (for example action: glabel_add)
param limit:maximum number of messages (for example action: msg_delete)
param overwrite:
 to control if file should overwrite (for example action: msg_attachment_save)
return:result object

Examples

*** Tasks ***
${actions}=   Create List  msg_unflag  msg_read  msg_save  msg_attachment_save
Do Message Actions    SUBJECT "Order confirmation"
...                   ${actions}
...                   source_folder=XXX
...                   target_folder=${CURDIR}
...                   overwrite=True

Flag Messages

Mark messages as `flagged`

Arguments

Argument Type Default value Description
criterionstrNone
unflagboolFalse

Mark messages as flagged

param criterion:
 mark messages matching criterion
param unflag:to mark messages as not flagged
return:successful operations (int), matching messages (int)

Examples

*** Tasks ***
${flagged}  ${oftotal}    Flag Messages   SUBJECT rpa
${unflagged}  ${oftotal}  Flag Messages   SUBJECT rpa  unflag=True

Get Folder List

Get list of folders on the server

Arguments

Argument Type Default value Description
subdirectorystrNone
patternstrNone
param subdirectory:
 list subdirectories for this folder
param pattern:list folders matching this pattern
return:list of folders

Examples

*** Tasks ***
@{folders}  Get Folder List
@{folders}  Get Folder List  pattern=important
@{folders}  Get Folder List  subdirectory=sub

List Messages

Return list of messages matching criterion.

Arguments

Argument Type Default value Description
criterionstr
source_folderstrNone
param criterion:
 list emails matching this, defaults to ""
return:list of messages or False

Examples

*** Tasks ***
@{emails}  List Messages  SUBJECT "rpa task"
FOR  ${email}  IN  @{EMAILS}
    Log  ${email}[Subject]
    Log  ${email}[From]
    Log  ${email}[Date]
    Log  ${email}[Delivered-To]
    Log  ${email}[Received]
    Log  ${email}[Has-Attachments]
END

Mark As Read

Mark messages as `read`

Arguments

Argument Type Default value Description
criterionstrNone
unreadboolFalse

Mark messages as read

param criterion:
 mark messages matching criterion
param unread:to mark messages as not read
return:successful operations (int), matching messages (int)

Examples

*** Tasks ***
${read}  ${oftotal}  Mark As Read   SUBJECT rpa

Mark As Unread

Mark messages as not `read`

Arguments

Argument Type Default value Description
criterionstrNone

Mark messages as not read

param criterion:
 mark messages matching criterion
return:successful operations (int), matching messages (int)

Examples

*** Tasks ***
${unread}  ${oftotal}  Mark As Unread   SUBJECT rpa

Move Messages

Move messages from source folder to target folder

Arguments

Argument Type Default value Description
criterionstrNone
target_folderstrNone
source_folderstrNone
param criterion:
 move messages matching criterion
param source_folder:
 location of the messages, default INBOX
param target_folder:
 where messages should be move into

Examples

*** Tasks ***
${result}=    Move Messages
...    criterion=SUBJECT "order confirmation 32"
...    target_folder=yyy

${result}=    Move Messages
...    criterion=ALL
...    source_folder=yyy
...    target_folder=XXX

Remove Gmail Labels

Remove GMail labels to messages matching criterion and if given, source folder

Arguments

Argument Type Default value Description
labelsnull
criterionnull
source_folderstrNone

Remove GMail labels to messages matching criterion and if given, source folder

param labels:comma separated list of labels to remove
param criterion:
 unlabel messages matching criterion
param source_folder:
 look for messages in this folder, default all folders
return:status of the operation

Examples

*** Tasks ***
Remove Gmail Labels  wip  SUBJECT "order confirmation"
Remove Gmail Labels  wip  SUBJECT "order confirmation"  customerfolder

Rename Folder

Rename email folder

Arguments

Argument Type Default value Description
oldnamestrNone
newnamestrNone
suppress_errorboolFalse
param oldname:current folder name
param newname:new name for the folder
param suppress_error:
 to silence warning message, defaults to False
return:True if operation was successful, False if not

Examples

*** Tasks ***
Rename Folder   subfolder   filtered

Save Attachment

Save mail attachment into local folder

Arguments

Argument Type Default value Description
messagedict, Messagenull
target_folderstrnull
overwriteboolnull
param message:message item
param target_folder:
 local folder for saving attachments to (needs to exist), defaults to user's home directory if None
param overwrite:
 overwrite existing file is True, defaults to False

Examples

*** Tasks ***
@{emails}  List Messages  SUBJECT "rpa task"
FOR  ${email}  IN  @{emails}
    Run Keyword If   ${email}[Has-Attachments] == True
    ...              Save Attachment  ${email}  target_folder=${CURDIR}  overwrite=True
END

Save Attachments

Save mail attachments into local folder.

Arguments

Argument Type Default value Description
criterionstr
target_folderstrNone
overwriteboolFalse
param criterion:
 attachments are saved for mails matching this, defaults to ""
param target_folder:
 local folder for saving attachments to (needs to exist), defaults to user's home directory if None
param overwrite:
 overwrite existing file is True, defaults to False
return:list of saved attachments or False

Examples

*** Tasks ***
${numsaved}  Save Attachments   SUBJECT "rpa task"
...          target_folder=${CURDIR}${/}messages  overwrite=True

Save Messages

Save messages based on criteria and store them to target folder with attachment files.

Arguments

Argument Type Default value Description
criterionstr
target_folderstrNone

Save messages based on criteria and store them to target folder with attachment files.

Does not save message if target_folder is not given.

param criterion:
 filter messages based on this, defaults to ""
param target_folder:
 path to folder where message are saved, defaults to None
return:True if success, False if not

Examples

*** Tasks ***
Save Messages  SUBJECT Important message  target_folder=${USERDIR}${/}messages

Select Folder

Select folder by name

Arguments

Argument Type Default value Description
folder_namestrINBOX
param folder_name:
 name of the folder to select
return:message count in the selected folder

Returns number of messages in the folder or exception if folder does not exist on the server.

Examples

*** Tasks ***
Select Folder   subfolder

Send Message

Send SMTP email

Arguments

Argument Type Default value Description
senderstrnull
recipientsstrnull
subjectstr
bodystr
attachmentsstr, NoneNone
htmlboolFalse
imagesstr, NoneNone
param sender:who is sending, ie. 'from'
param recipients:
 who is receiving, ie. 'to'
param subject:mail subject field
param body:mail body content
param attachments:
 list of filepaths to attach, defaults to []
param html:if message content is in HTML, default False
param images:list of filepaths for inline use, defaults to []

Valid sender values:

Examples

*** Tasks ***
Send Message  sender@domain.com  recipient@domain.com
...           subject=Greetings Software Robot Developer
...           body=${email_body}
...           attachments=${CURDIR}${/}report.pdf

Send Smtp Hello

Send hello message to SMTP server.

Required step when creating SMTP connection.

Set Credentials

Set credentials

Arguments

Argument Type Default value Description
accountstr, NoneNone
passwordstr, NoneNone
param account:user account as string, defaults to None
param password:user password as string, defaults to None

Examples

*** Tasks ***
Set Credentials   ${username}   ${password}
Authorize

Unflag Messages

Mark messages as not `flagged`

Arguments

Argument Type Default value Description
criterionstrNone

Mark messages as not flagged

param criterion:
 mark messages matching criterion
return:successful operations (int), matching messages (int)

Examples

*** Tasks ***
${unflagged}  ${oftotal}  Unflag Messages   SUBJECT rpa

Wait For Message

Wait for email matching `criterion` to arrive into mailbox.

Arguments

Argument Type Default value Description
criterionstr
timeoutfloat5.0
intervalfloat1.0

Wait for email matching criterion to arrive into mailbox.

param criterion:
 message filter to wait for, defaults to ""
param timeout:total time in seconds to wait for email, defaults to 5.0
param interval:time in seconds for new check, defaults to 1.0
return:list of messages or False

Examples

*** Tasks ***
@{emails}  Wait For Message  SUBJECT "rpa task"  timeout=300  interval=10