Email automation imap unread

I use the “IMAP” for receiving email.
I want to set read mark for special email.
for example title contained some word.
I set option “MarkAsRead”. But all email set READ.
So I unset option “MarkAsRead”.
and then I search some email.

the problem is how to set the state READ using imap

i searched in internet
Email.Net.Imap.ImapClient.MarkAsSeen(uid, inbox)
function is possible.
but how to use in UiPATH


Welcome to Forums

If you are using IMAP, It will collect all the Unread Messages, so if you Enable MarkasRead then all message will be read.

If you want to set only few mails then try the Filter option, this way you can filter the mails to get

Hope this helps


hi @HBbang

Please find the similar case i used for Outlook this will help for IMAP also,Main.xaml (7.2 KB)

Try below steps:Filter based on Subject,

  1. Get IMAP Mail Message activity will give output as list of mail messages and say ‘mailMessages’.
  2. Then use below expression to apply filter based on subject of the mails.

mailMessages = mailMessages.AsEnumerable().Where(Function(x) x.Subject.ToString.Equals(“requiredSubject”)).ToList


Please check the below post this might help you.

If it works,Please mark it as solution.



You could use some available mail-client library like MailKit

and code this using InvokeCode activity


how to use IMAP filter… I can not find the way

thank you… I try it

To filter SMTP mails Based on subject of the mails, you can try this

mailMessages = mailMessages.AsEnumerable().Where(Function(x) x.Subject.ToString.Equals(“requiredSubject”)).ToList

what if my subjects are in excel sheet ?

While doing assignment of display subject of first 5 unread mail. I am getting following error. I think it is because of Type mismatch. Please guide me.

After running code :
Error ERROR Validation Error Compiler error(s) encountered processing expression “email.Subject”.
‘Subject’ is not a member of ‘System.Collections.Generic.List(Of System.Net.Mail.MailMessage)’. GetUnReadGmailMessages.xaml