Hello UiPath forum Family,
I am trying to read all emails with specific subject name for example (Subject = "Excel Report ") extraction of all mail with same subject is successful but I just need read only latest mail and download attachment
If two subject name mail is in latest one mail the bot will read first which came recently
You steps would be a Follows below!
Get mail message Activity!
For each Item in Mailout
If Item.Subject.equals(“YourSubjectKey”)
Then Save attachments!
Regards
Hello @pravin_calvin
Get mail message Activity!
For each Item in Mailout
If Item.Subject.contains(“YourSubjectKey”)
Then Save attachments!
“Equals” is not work I used "Contains"this logic will fetch mails but bot save more than 2 files because there is more than one mail of same subject. I need just latest one mail
Hi @sandip.shahane,
In your get email activity you can set the property Top to 1 and you will only fetch one email.
I don’t know if you use Outlook but this is the example for that:
Also for the solution suggested before, you could use a Break activity after saving the attachment of the first email inside your For Each loop.
Best,
Daniela
In addition to @Daniela_Colina’s latest post, I would look updating your Exchange Package so you can add a filter expression to find the exact email and the most recent.
So,
- Select “Newest First” in “OrderByDate”
- Insert “1” into “Top”
- Insert expression into the “FilterExpression” field. Insert this expression: "subject:Excel Report "
The UiPath documentation for Get Exchange Mail Messages and the filter examples are really good. You can add many filter types.
Hopefully this helps
Hi @Steven_McKeering ,
I am using Gmail get mail message activity
I was try date order : “News first” and filter expression “subject:Excel Report” but it showing this error
Hi @Daniela_Colina ,
I am using Gmail get IMAP mail message
I was try you solution but couldn’t work can you please tell me how filter condition in get IMAP mail message activity.
Here is image
Hi
Your expression looks fine
Hmm
May be You can try this approach:
- Read the mails using Get IMAP mail activity and store in mails variable.
- Now use the below linq query using assign activity
mails= mails.Where(Function(mail) mail.Subject.ToString.ToUpper.Contains(“EXCEL REPORT”)).ToList()
the after the assign activity, mails variable will only contain the mail which had subject containing the word you want in it.
Cheers @sandip.shahane
Hello @Palaniyappan ,
Thank you for sweet words I have one doubt this expression will get latest first mail only and then next mail with same subject will not save because i want this logic if subject name mail is there continue one by one bot will pick only first new mail
Regards,
Sandip
Hi @Daniela_Colina ,
I used break activity in for each loop so bot iterating email one by one but save only latest file attachment
Thanks for help
Regards,
Sandip Shahane
Hi @sandip.shahane,
Have you tried with the filter “SUBJECT ““Excel Report””” ?
There are examples on how to filter using the IMAP activity in uipath’s documentation:
Best,
Daniela
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.