UiPath

UiPath MicrosoftOffice365 Outlook related activity use case

In UiPath Studio development, there are cases where we want to manipulate Outlook emails in Office365.

This article describes how to manipulate Outlook email in Office365 using Microsoft Office365 Activities.

 

 Related Articles Learn the Creation Techniques f UiPath robotics creation with Udemy’s online courses that take it up a notch

This site was created by translating a blog created in Japanese into English using the DeepL translation.

Please forgive me if some of the English text is a little strange

How to Prepare and Use Office365 Activities

How to Install Office365 Activities

Microsoft Office365 Activities are not present in the process created by default.

A separate MicrosoftOffice365.Activities activity package must be added.

 

For instructions on how to install Microsoft Office365 Activities, please refer to the Installing the Office365 Activities Package article.

 

How to use Office365 Activities

Each Office365 activity is used by placing the activity within the “Microsoft Office 365 Scope” or “Use OneDrive and SharePoint”.

The “Microsoft Office 365 Scope” is recommended since all activities under the “Integration>Microsoft>Office365” can be used.

However, “App Registration” must be configured for AzureAD.

 

F-pen
F-pen
See Authentication with Microsoft Office 365 Scope for specific setup instructions.

“Use OneDrive and SharePoint” only uses activities under the “Integration>Microsoft>Office365>Files” and can only manipulate files on Office365.

sea other
sea other
See Authentication with OneDrive and SharePoint for specific setup instructions.

 

List of file manipulation activities in Office365

Activities that manipulate Office365 files can be found under “Integration>Microsoft>Office365>Outlook”.

 

The following table shows the activities under “Integration>Microsoft>Office365>Outlook”.

Activity Location Activity Name What you can do in Activities
Integrations> Microsoft> Office365>
Outlook
Reply to Mail Uses the Microsoft Graph Create Reply and Reply APIs to reply to an email message.
Set Mail Categories Uses the Microsoft Graph Update message API to associate categories with a message.
Delete Mail Uses the Microsoft Graph Delete message API to delete an email message.
Get Mail Uses the Microsoft Graph Get message and List messages APIs to retrieve the matching messages from a specified mailbox (Mailbox).
Move Mail Uses the Microsoft Graph Move event message API to move a message (Message) to a different mail folder (DestinationFolder).
Forward Mail Uses the Microsoft Graph Create forward and Forward event message API to forward a message (Message), with additional content (Body), to one or more recipients (To).
Send Mail Uses the Microsoft Graph Create message and Send mail APIs to send a message (Body and Subject) to one or more recipients (To, CC, and BCC).

 

F-pen
F-pen
For other activities, see the list of Office365 activities.

 

 

Outlook email operations in Office365

To manipulate Outlook email in Office365, use the activity found under “Integration>Microsoft>Office365>Outlook”.

sea other
sea other
In this chapter, I’ll show you some examples of frequently used activities.

 

Get Mail

To manipulate the mail in Outlook, first retrieve the “Office365Message” array by searching for it in the “Get Mail” activity.

The retrieved Office365Message can then be used in other activities to forward, move, etc.

 

Get Mail

Setting Location Setting item Setting details
Properties Common DisplayName The display name of the activity.
Input Account (Optional) The email address with which to interact.
Mail Folder The mail folder from which the messages are retrieved.
Misc Private If selected, the values of variables and arguments are no longer logged at Verbose level.
Options Get As HTML If selected, the message body is returned in HTML format.
Mark As Read If selected, the returned messages are marked as read.
Only Unread Messages If selected, only unread messages are returned. The default value is True.
Order By Date The returned messages are ordered by date. The available options are NewestFirst and OldestFirst.
Query Query used for filtering the returned emails.
Top The maximum number of emails to retrieve.
Output Result Returns all emails from the user’s inbox.

 

 

 

sample process
A user logged into Office365 at the time of workflow execution, retrieves three messages in the Outlook inbox and displays the message subject in the log message.

 

・variable

 

・Properties of “Microsoft Office 365 Scope”

 

・Properties of “Get Mail”

F-pen
F-pen
By setting the maximum number of options to 3, a maximum of 3 emails will be retrieved.
sea other
sea other
To retrieve from new mail, select NewestFirst for sort by date in the options.

 

・Target inbox to retrieve email from

 

・Log of workflow execution results

F-pen
F-pen
I am able to display the subject lines of 3 new emails in the log.

 

Send Mail

Use the “Send Mail” activity to send an email in Outlook.

 

Send Mail setting items

Setting Location Setting item Setting details
Properties Attachments Attachments A collection containing the paths to the files attached to the email.
Attachments Collection An additional list of files attached to the message.
Common DisplayName The display name of the activity.
Email Body The email’s message body.
Subject The subject of the email.
Input Account (Optional) The email address with which to interact.
Misc Private If selected, the values of variables and arguments are no longer logged at Verbose level.
Options From The email address from which the email is sent.
Importance The importance of the mail message.
Is Body HTML If selected, the body of the email is interpreted in HTML format.
Is Draft If selected, the message is saved as a draft and not sent.
Reply to The email addresses to use when replying.
Recipients Bcc A comma-separated list of email addresses that you want to be included as Bcc recipients.
Cc A comma-separated list of email addresses that you want to be included as Cc recipients.
To A comma-separated list of email addresses that you want to send your mail to.

 

 

sample process
Send email with Outlook in Office365.

 

・Variable

 

・Properties of “Microsoft Office 365 Scope”

 

・Properties of “Send Mail”

 

・Send items after workflow execution

sea other
sea other
There is an email executed by UiPath in Send Items.

 

Forward Mail

To forward an email in Outlook, first search for it in the “Get Mail” activity and get it as an array of type “Office365Message”.

Next, the acquired Office365Message is used in “Forward Mail” to forward the mail.

 

Forward Mail setting items

Setting Location Setting item Setting details
Properties Attachments Attachments A collection containing the paths to the files to be attached to the email.
Attachments Collection An additional list of files to be attached to the email.
Replace Existing Indicates whether to replace the existing attachments with the same name.
Common DisplayName The display name of the activity.
Input Account (Optional) The email address with which to interact.
Body The email’s message body.
Message The email to forward. This field supports only Office365Message variables.
New Subject The new subject of the email.
Misc Private If selected, the values of variables and arguments are no longer logged at Verbose level.
Options Is Draft If selected, the message is saved as a draft and not sent.
Recipients Bcc A list of additional email addresses that you want to add as Bcc recipients.
Cc A list of additional email addresses that you want to add as Cc recipients.
To A comma-separated list of email addresses that you want to send your mail forward to.

 

 

sample process
When executing a workflow, a user logged into Office365 can retrieve up to five messages in the Outlook Inbox with the subject line “Email Notification” and forward the email to another user.

 

・Variable

 

・Properties of “Microsoft Office 365 Scope”

 

・Properties of “Get Mail”

sea other
sea other
To search for messages with “Notice” in the subject line, the query is “contains(subject,’Notice’)”.
F-pen
F-pen
For more information and examples of how to use the query, please refer to the optional query “Get Mail” and the “filter parameter“.

 

・Properties of “For Each”

sea other
sea other
Set UiPath.MicrosoftOffice365.Models.Office365Message to TypeArgument to set each value in the Office365Message array to item.

 

・Properties of “Forward Mail”

 

・Inbox for mail retrieval

 

 

・Sent items after workflow execution

F-pen
F-pen
Two messages were forwarded because there were two subject lines in the Inbox that contained the word “Notice”.

 

 

Move Mail

To move an email in Outlook, first search for it in the “Get Mail” activity and get it as an array of type “Office365Message”.

Next, the retrieved Office365Message is used in “Move Mail” to move the mail.

 

Move Mail setting items

設定場所 設定項目 設定内容
Properties Common DisplayName The display name of the activity.
Input Account (Optional) The email address with which to interact.
DestinationFolder The destination folder’s name.
Message The message to move.
Misc Private If selected, the values of variables and arguments are no longer logged at Verbose level.

 

 

 

sample process
A user logged into Office365 at the time of workflow execution, retrieves one message with the sender “fpenuser02@*******.onmicrosoft.com” in the Outlook Inbox and moves the email to the “Archive” folder.

 

 

・variable

 

・Properties of “Microsoft Office 365 Scope”

 

・Properties of “Get Mail”

 

 

・Properties of “For Each”

 

・Properties of “Move Mail”

 

・Inbox before process execution

 

・Archive before process execution

 

・Archive after process execution

F-pen
F-pen
A message from “fpenuser04@fpen0316.onmicrosoft.com” (fpen user04) in your Inbox has been moved to the “Archive”.

 

Delete Mail

To delete an email in Outlook, first search for it with the “Get Mail” activity and get it as an array of “Office365Message”.

Next, use “Delete Mail” with the obtained Office365Message to delete the mail.

 

Delete Mail setting items

設定場所 設定項目 設定内容
Properties Common DisplayName The display name of the activity.
Input Account (Optional) The email address with which to interact.
Message The message to delete.
PermanentlyDelete Indicates whether to delete the email permanently.
Misc Private If selected, the values of variables and arguments are no longer logged at Verbose level.

 

 

 

sample process
Delete the oldest message in the Outlook Inbox for the user logged into Office365 at the time of workflow execution.

 

 

・Variable

 

・Properties of “Microsoft Office 365 Scope”

 

・Properties of “Get Mail”

 

・Properties of “For Each”

 

・Properties of “Delete Mail”

 

 

・Inbox before workflow execution

 

・Inbox after workflow execution

・Delete tray after workflow execution

sea other
sea other
The earliest message, Sun 11:31, has been deleted.

 

 

 

summary

  • To manipulate Outlook email in Office365, first add the MicrosoftOffice365.Activities activity package.
  • Microsoft Office 365 Scope” to the workflow that manipulates Office365 email and place the “Integration>Microsoft>Office365>Outlook” activity within it.
  • The “Get Mail” activity searches the mail box and retrieves the results as an “Office365Message” type, which can then be used in other activities to manipulate the mail.

Back to Table of Contents

 

 Related Articles Learn the Creation Techniques f UiPath robotics creation with Udemy’s online courses that take it up a notch

 same category UiPath

 

The operator of this blog, F-penIT blog