Read Outlook Emails by UID

In multiple use cases I encounter the following issue:

I can’t retrieve a specific mail by specifying it’s UID.

Ex: I have an inbox where I receive multiple emails. The items should be performed by multiple Bots. After an item is done a reply should be send to the original email received.


  1. A dispatcher who fetch the emails, extract the UID and put it in the Queue with additional instructions for the bot.
  2. A bot perform specific activities for the item and at the end sends the reply to the original email.

The issue is that in order to get the data from the original email the bot should read all the emails in the inbox and then to iterate to find the right one. This is time consuming especially when you have more then 3000 emails per day.

The current implementation of the Get Outlook Mail Messages doesn’t offer the access to search by UID even if all the methods to get emails from an inbox have this function embedded.

I also tried to store the System.Net.Mail.MailMesage on Orchestrator but this doesn’t work either due to the fact that the object is not serialised.

@CristianZachiteanu - You query is to read e-mail from particular user?


My request is to be able to read a specific email based on its UID (unique Identifier) present in the mail headers and also available as Outlook.NameSpace.GetItemFromID in the VBA

1 Like

Hi @CristianZachiteanu - Yes this can be done by Looping through the Output of GetOutlookMailMessage and get Item.Header(“Message-ID”)


1 Like

Dear Kumar, if you have paid enough attention to my initial message you would have seen that I mentioned that this is a major issue when you have thousands emails per day because the iteration is slow an you need to perform it for each item so you will have 3000 iterations in 3000 items this means 9.000.000 (nine million) iterations. Not to take in consideration the overload performed in order to read 3000 emails for 3000 times from the outlook. I don’t understand why this functionality isn’t available since the process of reading the emails from the server is based directly on this UID.

I tried to build this for myself but there are different methods for reading emails from Outlook but they are returning either Microsoft.Office.Interop.Outlook.MailItem structure or System.Web.Mail.MailMessage. These structures are not the same with the System.Net.Mail.Mail.Message the GetOutlookMailMessages activity produces and there are no converters from one form to another. I think it will be a useful activity to be able to retrieve the original email from the Outlook based on a Unique Identifier instead of storing it locally or to be forced to iterate through thousands of emails.

Thank you

1 Like

Hi @CristianZachiteanu

Any chance you could use any other available field to create a condition for filtering the right emails? If I understand correctly, you would like the have the UID field be available as one of the properties of the filter property:

Would any other property from this list work as a workaround? (body, subject, etc)

I did add your idea to our idea tracker, but we should keep discussing all the workarounds :slight_smile:

1 Like

Hi, The filter field provided doesn’t have direct access to the UID.

It is possible to have a combination of different fields however this imply to store additional information in the Orchestrator and you will not be 100% sure that the combination is unique.

Thank you: :slight_smile:

1 Like

Hi Cristian,

please suggest on how you were able to extract the outlook emails to Microsoft.Office.Interop.Outlook.MailItem. I am trying to convert the mailmessage to mailitem but not successfull.


Hello @CristianZachiteanu ,

If you still need this, here is a custom activity for getting mails by UID.

I will kindly request a feedback or comment if you try the activity :slight_smile:



Hi @sarikayaebru I did try your solution and it is working great for emails stored in Inbox. However, I do have a case where I want to retrieve email by ID while it is being stored in subfolders. Is it possible for you to add this kind of functionality (either searching for mail in all available folders or in specified one) to the activity Get Outlook Mail Message With UID? Or at least to share the code for this activity?

Thanks :slight_smile:

Hey @Babla

Actually it searches the mail in all folders not only inbox (in the mailbox). But when you move the mail to another folder, Outlook changes the mail UID. If you get the UID before you move the mail, UID will be changed and the activity cannot be able to find it.

You can test this situation by comparing the same mail’s UID before and after moving it.

But I will search the possible solutions for this and will update the packages if I can find something. :slight_smile:

I found these fields extremely helpful, but when I aim to filter by Subject it will not match.

My filter on the mark as read side is
“[Subject] ='”+strBody+“'”
where strBody mail.Body.ToString


Thank you! its working great!

A solution to to the UID changing between folders would be amazing!!

1 Like

Hi @sarikayaebru , when you said that it searches “in all folders” do you mean also in all acounts? I have 2 different outlook accounts opened in the same machine

Check the activity UiPath mail.activities
there is a activity called get mail by id