Filter Outlook Mail Messages With UID

How to filter Outlook mail messages using UID?

Below is an approach using both the UiPath Marketplace Outlook Mail Activities and LINQ to filter Outlook mail messages based on UID:

Approach #1:

  1. Install UIPATH Outlook Mail Activities:
  1. Use "Get Outlook Mail Message With UID" Activity:
  • Once installed, navigate to the Activities tab.
    1. Drag and drop the "Get Outlook Mail Message With UID" activity into your workflow.
    2. Pass the UID in the activity's properties to retrieve the desired mail message.

Approach #2:

After executing the "Get Outlook Mail Message" activity, which returns a List of "MailMessage" objects, utilize LINQ (Language-Integrated Query) to filter the UID to obtain the matched mail messages.

Below is an example:

C #

// Assuming 'mailMessages' is the List obtained from the UIPATH activity

string targetUID = "your_target_UID_here";

// Use LINQ to filter the MailMessage list by UID

var filteredMessages = mailMessages.Where(message => message.Headers["UID"].Equals(targetUID)).ToList();

// 'filteredMessages' now contains all mail messages matching the specified UID

In the above code snippet, replace "your_target_UID_here" with the actual UID being searched for within the Outlook mail messages obtained from the UiPath Activity.

This approach utilizes LINQ's Where method to filter the mailMessages list based on the condition where the UID in the message headers matches the provided targetUID.

By implementing these approaches, it is possible to effectively retrieve and filter Outlook mail messages based on UID using UIPATH activities and LINQ within the workflows.