activities
latest
false
UiPath logo, featuring letters U and I in white
Productivity Activities
Last updated Nov 21, 2024

Get Outlook Mail Messages

UiPath.Mail.Outlook.Activities.GetOutlookMailMessages

Retrieves email messages from Outlook.

Properties

Input
  • MailFolder - The mail folder from which the messages are to be retrieved.
  • Account - The account used to access the messages that are to be retrieved.
Options
  • Filter - A string used as a filter for the messages to be retrieved. Accepts JET Queries or DASL Queries.
  • FilterByMessageIds - Returns only mail messages that match the specified message IDs. You can retrieve the message ID from the MailMessage object, for example, MailMessage.Headers("Message-ID"). If set, the Filter option is ignored.
  • MarkAsRead - Specifies whether to mark retrieved messages as read. By default, this check box is cleared.
  • OnlyUnreadMessages - Specifies whether to retrieve only unread messages. By default, this check box is selected.
  • OrderByDate - Orders mail messages by date. The available options are NewestFirst and OldestFirst.
  • Top - The number of messages to be retrieved starting from either the newest or the oldest, depending on the OrderByDate parameter.

    Important: If this field is empty, the activity returns no messages.
Common
  • DisplayName - The display name of the activity.
  • TimeoutMS - Specifies the amount of time (in milliseconds) to wait for the activity to run before an error is thrown. The default value is 30000 milliseconds (30 seconds).
Output
  • Messages - The retrieved messages as a collection of MailMessage objects.
    Note:

    Starting with UiPath.Mail.Activities version 1.10.4, the MailMessage object exposes:

    • The Message-ID of a mail message, for example MailMessage.Headers("Message-ID").
    • The Categories associated with a mail message, for example MailMessage.GetCategories().
    • For tracking the number of inline attachments in an email you need to access the first Alternate View and then get the count of all Linked Resources from that view. For example, item.AlternateViews(0).LinkedResources.Count.
Misc
  • Private - If selected, the values of variables and arguments are no longer logged at Verbose level.

Filtering Examples

The following table shows examples of filters that can be useful when you query Outlook mail messages:

Query

Filter Expression

All mail messages with subject "Product Roadmap"

"[Subject] = 'Product Roadmap'"

All mail messages with subject "Turn I can't into I can"

"[Subject] = 'Turn I can''t into I can'" (add a single quote as an escape character)

All mail messages with subject "Job application: "Business Analyst" position"

"[Subject] = 'Job application: ""Business Analyst"" position'" (add a double quote as an escape character)

All mail messages containing "business analyst" string in the subject

"@SQL=""urn:schemas:httpmail:subject"" like '%business analyst%'"

All mail messages with the subject starting with "job"

"@SQL=""urn:schemas:httpmail:subject"" like 'job%'"

All mail messages from "Anthony Young"

"[SenderName] = 'Anthony Young'"

"[From] = 'Anthony Young'"

All mail messages from "[email protected]"

"[SenderEmailAddress] = '[email protected]'"

All mail messages containing "UiPath IT Automation" string in the body

"@SQL=""urn:schemas:httpmail:textdescription"" like '%UiPath IT Automation%'"

All mail messages with the body starting with "UiPath.Mail.Activities" string

"@SQL=""urn:schemas:httpmail:textdescription"" like 'UiPath.Mail.Activities%'"

All mail messages flagged with "Review"

"[FlagRequest] = 'Review'"

All mail messages flagged with "Follow up" or "Review"

"[FlagRequest] = 'Follow up' OR [FlagRequest] = 'Review'"

All mail messages with due date this week

"[Due date] = 'This week'"

All mail messages with due date tomorrow

"[Due date] = 'Tomorrow'"

All mail messages with due date on 01/21/2021

"[Due Date] = '01/21/2021'"

All mail messages with high importance

"[Importance] = High"

All confidential mail messages

"[Sensitivity] = Confidential"

All mail messages having 'Red category' and 'Blue category' as their categories

"[Categories] = 'Red category' AND [Categories] = 'Blue category'"

"[Categories] = 'Red category, Blue category'"

All mail messages received today

"[Received] >= '" + DateTime.Today.ToString("d") + " 00:00AM'"

"[ReceivedTime] >= '" + DateTime.Today.ToString("d") + " 00:00AM'"

All mail messages received yesterday

"[Received] >= '" + DateTime.Today.AddDays(-1).ToString("d") + " 00:00AM' AND [Received] < '"+ DateTime.Today.ToString("d") + " 00:00AM'"

All mail messages received since yesterday at 22:00

"[ReceivedTime] >= '" + DateTime.Now.AddDays(-1).ToString("d") +" 22:00'"

All mail messages received in the last hour

"[ReceivedTime] >= '" + DateTime.Now.AddHours(-1).ToString("MM/dd/yyyy HH:mm tt") + "'"

All mail messages received in the last 15 minutes

"[ReceivedTime] >= '" + DateTime.Now.AddMinutes(-15).ToString("MM/dd/yyyy HH:mm tt") + "'"

All mail messages sent in the last 15 minutes (MailFolder should be set to "Sent Items")

"[SentOn] >= '" + DateTime.Now.AddMinutes(-15).ToString("MM/dd/yyyy HH:mm tt") + "'"

For more information, you can view the following pages:

  • Properties
  • Filtering Examples

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.