Close Document

Close the active document (if open).

Arguments

Argument Type Default value Description
save_changesboolFalseif changes should be saved on close, default False
param save_changes:
 if changes should be saved on close, default False

Get Emails

Get emails from a specified email folder. Can be used to save attachments.

Arguments

Argument Type Default value Description
account_namestr, NoneNoneneeds to be given if there are shared accounts in use, defaults to None
folder_namestr, NoneNonetarget folder where to get emails from, default Inbox
email_filterstr, NoneNonehow to filter email, default no filter, ie. all emails in folder
save_attachmentsboolFalseif attachments should be saved, defaults to False
attachment_folderstr, NoneNonetarget folder where attachments are saved, defaults to current directory
sortboolFalseif emails should be sorted, defaults to False
sort_keystr, NoneNoneneeds to be given if emails are to be sorted
sort_descendingboolTrueset to False for ascending sort, defaults to True
param account_name:
 needs to be given if there are shared accounts in use, defaults to None
param folder_name:
 target folder where to get emails from, default Inbox
param email_filter:
 how to filter email, default no filter, ie. all emails in folder
param save_attachments:
 if attachments should be saved, defaults to False
param attachment_folder:
 target folder where attachments are saved, defaults to current directory
param sort:if emails should be sorted, defaults to False
param sort_key:needs to be given if emails are to be sorted
param sort_descending:
 set to False for ascending sort, defaults to True
return:list of emails (list of dictionaries)

Examples

${emails}=  Get Emails
...    email_folder=priority
...    email_filter=[Subject]='incoming order'
...    save_attachments=True
...    attachment_folder=%{ROBOT_ROOT}${/}attachments
...    sort=True
...    sort_key=Received
...    sort_descending=False

Mark Email As Read

Mark email 'read' property. Can be used to mark email as unread.

Arguments

Argument Type Default value Description
emailAnynulltarget email
readboolTrueTrue marks email as Read, False as Unread
param email:target email
param read:True marks email as Read, False as Unread

Examples

${emails}=  Get Emails
# Mark all as read
FOR  ${email}  IN  @{emails}
    Mark Email As Read  ${email}
END

# Mark all as unread
FOR  ${email}  IN  @{emails}
    Mark Email As Read  ${email}  False
END

Move Emails

Move emails from source folder to target folder.

Arguments

Argument Type Default value Description
account_namestr, NoneNoneneeds to be given if there are shared accounts in use, defaults to None
source_folderstr, NoneNonefolder where source emails exist
email_filterstr, NoneNonehow to filter email, default no filter, ie. all emails in folder
target_folderstr, NoneNonefolder where emails are moved into

Use of "account_name" is recommended if there are shared accounts in use.

param account_name:
 needs to be given if there are shared accounts in use, defaults to None
param source_folder:
 folder where source emails exist
param email_filter:
 how to filter email, default no filter, ie. all emails in folder
param target_folder:
 folder where emails are moved into
return:True if move operation was success, False if not

Examples

# moving messages from Inbox to target_folder
Move Emails
...    target_folder=Processed Invoices
...    email_filter=[Subject]='incoming invoice'

# moving messages from source_folder to target_folder
Move Emails
...    source_folder=Incoming Invoices
...    target_folder=Processed Invoices
...    email_filter=[Subject]='incoming invoice'

Open Application

Open the Outlook application.

Arguments

Argument Type Default value Description
visibleboolFalseshow window after opening, default False
display_alertsboolFalseshow alert popups, default False
param visible:show window after opening, default False
param display_alerts:
 show alert popups, default False

Quit Application

Quit the application.

Arguments

Argument Type Default value Description
save_changesboolFalseif changes should be saved on quit, default False
param save_changes:
 if changes should be saved on quit, default False

Save Email Attachments

Save email attachments.

Arguments

Argument Type Default value Description
attachmentsAnynullall attachments from email or single attachment
attachment_folderstrnulltarget folder where attachments are saved, defaults to current directory
overwriteboolFalseoverwrite existing file if True, defaults to False

Note. Keyword "Get Emails" can be also used to save attachments.

param attachments:
 all attachments from email or single attachment
param attachment_folder:
 target folder where attachments are saved, defaults to current directory
param overwrite:
 overwrite existing file if True, defaults to False

Examples

${emails} =  Get Emails
...    email_folder=priority
FOR  ${email}  IN   @{emails}
    FOR  ${attachment}  IN  @{email}[Attachments]
        IF  ${attachment}[size] < 100000   # bytes
            Save Email Attachments
            ...  ${attachment}
            ...  ${CURDIR}${/}attachments
        ELSE IF  ".pdf" in "${attachment}[filename]"
            Save Email Attachments
            ...  ${attachment}
            ...  ${CURDIR}${/}attachments${/}pdf
        END
    END
END

Send Email

Send email with Outlook

Arguments

Argument Type Default value Description
recipientsstr, List[str]nulllist of addresses
subjectstrnullemail subject
bodystrnullemail body
html_bodyboolFalseTrue if body contains HTML, defaults to False
attachmentsstr, List[str], NoneNonelist of filepaths to include in the email, defaults to []
save_as_draftboolFalseemail is saved as draft when True
cc_recipientsstr, List[str], NoneNonelist of addresses for CC field, default None
bcc_recipientsstr, List[str], NoneNonelist of addresses for BCC field, default None
param recipients:
 list of addresses
param subject:email subject
param body:email body
param html_body:
 True if body contains HTML, defaults to False
param attachments:
 list of filepaths to include in the email, defaults to []
param save_as_draft:
 email is saved as draft when True
param cc_recipients:
 list of addresses for CC field, default None
param bcc_recipients:
 list of addresses for BCC field, default None
return:True if there were no errors

Examples

library = Outlook()
library.open_application()
cc_recipients = ["recipient3@domain.com","recipient4@domain.com"]
library.send_email(
    recipients="recipient1@domain.com",
    cc_recipients=cc_recipients,
    bcc_recipients="recipient3@domain.com;recipient4@domain.com",
    subject="hello from Outlook",
    body="empty body",
    attachments=os.path.join(os.path.curdir, "example.xslx")
)
${cc}=  Create List   recipient3@domain.com   recipient4@domain.com
Send Email
...    recipients=recipient1@domain.com
...    cc_repients=${cc}
...    bcc_repients=recipient5@domain.com;recipient6@domain.com
...    subject=hello from Outlook
...    body=empty body
...    attachments=${CURDIR}${/}example.xlsx

Send Message

Send message with Outlook

Arguments

Argument Type Default value Description
recipientsstr, List[str]nulllist of addresses
subjectstrnullemail subject
bodystrnullemail body
html_bodyboolFalseTrue if body contains HTML, defaults to False
attachmentsstr, List[str], NoneNonelist of filepaths to include in the email, defaults to []
save_as_draftboolFalsemessage is saved as draft when True instead (and not sent)
cc_recipientsstr, List[str], NoneNone
bcc_recipientsstr, List[str], NoneNone
param recipients:
 list of addresses
param subject:email subject
param body:email body
param html_body:
 True if body contains HTML, defaults to False
param attachments:
 list of filepaths to include in the email, defaults to []
param save_as_draft:
 message is saved as draft when True instead (and not sent)
return:True if there were no errors

Wait For Email

Wait for email matching criterion to arrive into mailbox.

Arguments

Argument Type Default value Description
criterionstr, NoneNoneemail filter to wait for, defaults to ""
timeoutfloat5.0total time in seconds to wait for email, defaults to 5.0
intervalfloat1.0time in seconds for new check, defaults to 1.0
param criterion:
 email 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

Possible wait criterias are: SUBJECT, SENDER and BODY

Examples

Wait for Email     SUBJECT:rpa task calling    timeout=300    interval=10

Wait For Message

Wait for email matching criterion to arrive into mailbox.

Arguments

Argument Type Default value Description
criterionstr, NoneNonemessage filter to wait for, defaults to ""
timeoutfloat5.0total time in seconds to wait for email, defaults to 5.0
intervalfloat1.0time in seconds for new check, defaults to 1.0
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

Possible wait criterias are: SUBJECT, SENDER and BODY

Examples

Wait for message     SUBJECT:rpa task calling    timeout=300    interval=10