RPA.Outlook.Application
Close the active document and app (if open).
Arguments
Argument | Type | Default value |
---|---|---|
save_changes | bool | False |
param save_changes: | Enable changes saving on quit. (False by default) |
---|
Get emails from a specified email folder. Can be used to save attachments.
Arguments
Argument | Type | Default value |
---|---|---|
account_name | str, None | None |
folder_name | str, None | None |
email_filter | str, None | None |
save_attachments | bool | False |
attachment_folder | str, None | None |
sort | bool | False |
sort_key | str, None | None |
sort_descending | bool | 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) |
Usage
${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 'read' property. Can be used to mark email as unread.
Arguments
Argument | Type | Default value |
---|---|---|
Any | null | |
read | bool | True |
param email: | target email |
---|---|
param read: | True marks email as Read, False as Unread |
Usage
${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 from source folder to target folder.
Arguments
Argument | Type | Default value |
---|---|---|
account_name | str, None | None |
source_folder | str, None | None |
email_filter | Any, None | None |
target_folder | str, None | None |
mark_as_read | bool | True |
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 |
param mark_as_read: | mark emails as read after move, defaults to True |
return: | True if move operation was success, False if not |
Python example.
outlook = RPA.Outlook.Application()
# moving messages from Inbox to target_folder
outlook.move_emails(
target_folder='Processed Invoices',
email_filter="[Subject]='incoming invoice'"
)
# moving messages from source_folder to target_folder
outlook.move_emails(
source_folder='Incoming Invoices',
target_folder='Processed Invoices',
email_filter="[Subject]='incoming invoice'"
)
# move message objects from get_emails result
emails = outlook.get_emails("[Subject]='incoming invoice'")
outlook.move_emails(
target_folder='Processed Invoices',
email_filter=emails
)
Robot Framework example.
# 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'
# moving message objects from Get Emails result
${emails}= Get Emails [Subject]='incoming invoice'
Move Emails
... target_folder=Processed Invoices
... email_filter=${emails}
Open the application.
Arguments
Argument | Type | Default value |
---|---|---|
visible | bool | False |
display_alerts | bool | False |
param visible: | Show the window on opening. (False by default) |
---|---|
param display_alerts: | Display alert popups. (False by default) |
Quit the application.
Arguments
Argument | Type | Default value |
---|---|---|
save_changes | bool | False |
param save_changes: | Enable to save changes on quit. (False by default) |
---|
Save email attachments.
Arguments
Argument | Type | Default value |
---|---|---|
attachments | Any | null |
attachment_folder | str | null |
overwrite | bool | 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 |
Usage
${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 with Outlook
Arguments
Argument | Type | Default value |
---|---|---|
recipients | str, List[str] | null |
subject | str | null |
body | str | null |
html_body | bool | False |
attachments | str, List[str], None | None |
save_as_draft | bool | False |
cc_recipients | str, List[str], None | None |
bcc_recipients | str, List[str], None | None |
reply_to | str, List[str], None | None |
check_names | bool | False |
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 |
param reply_to: | list of addresses for changing email's reply-to field, default None |
param check_names: | all recipients are checked if the email address is recognized on True, default False |
return: | True if there were no errors |
Usage
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
Set the property of any object.
Arguments
Argument | Type | Default value |
---|---|---|
object_instance | null | |
property_name | str | null |
value | str | null |
This is a utility keyword for Robot Framework syntax to set object property values.
${new_value}= Replace String ${value} 10.132. 5511.11.
Set Object Property ${result} Value ${new_value}
param object_instance: | object instance to set the property |
---|---|
param property_name: | property name to set |
param value: | value to set |
Wait for email matching criterion to arrive into mailbox.
Arguments
Argument | Type | Default value |
---|---|---|
criterion | str, None | None |
timeout | float | 5.0 |
interval | float | 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
Usage
Wait for Email SUBJECT:rpa task calling timeout=300 interval=10