What is the Correct Format of writing Filter Expression in Get IMAP Mail Messages Activity?

Hi,

Could someone please help me with the correct format value to be entered in the FilterExpression Property of Get IMAP Email Messages Activity (yellow highlighted in below snapshot)

image

I was trying to apply a filter like : “SUBJECT ” (Please ignore angular brackets as part of filter expression) to filter the mails which contains in the Subject, as per the Uipath Official Documentation as below:

But My Bot is failing with below error Message :
Get IMAP Mail Messages: The IMAP server replied to the ‘SEARCH’ command with a ‘BAD’ response: The specified message set is invalid.

Any help would be really appreciated !!

Regards
Sandeep Negi

1 Like

Hi @sandy.randy95

For Get IMAP Mail Message Activity, we don’t have any option. But you can use Get Outlook MailMessage Activity to do this and it has direct option like Filter. By using this, we can filter our mails based on subject, body and sender etc…

If you want to work with Outlook application it should be installed in our machine and also it should be in online.

Hi Gokul,

Thank you for your Response !
I believe we have this option available in Get IMAP Mail Message Activity, PFB the Screenshot for your reference(yellow highlighted). I am using Uipath 2021.4.4 Community Edition.

Also, I don’t have any specific requirement, I was just exploring all the Email Activities and came across this one. I wanted to understand how this property works and its significance and how to enter filter expressions in this property. By following Uipath Official Documents(to enter Filter expressions), it is giving me below error:

Get IMAP Mail Messages: The IMAP server replied to the ‘SEARCH’ command with a ‘BAD’ response: The specified message set is invalid.

I hope you have understood my query !

Regards
Sandeep Negi

Hi @sandy.randy95

I think so this sample expression will help you
Try below steps:

  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

Any one have found the Solution for this. please help @loginerror . I just faced the similar issue

@Vijay_RPA @sandy.randy95 For me it works exactly how I detailed the examples in the documentation. It worked also with a simpler search expression like FilterExpression = “SUBJECT test” to return the emails that contain test in their subject.

I checked with Mail activities pack version 1.12.3 with server = “outlook.office365.com” and port = 993.

For more details you can check RFC 3501 - INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1

1 Like

Thank you @ovidiuponoran am just testing for imap.gmail.com. will look again but What if i have filter with more subjects like SUBJECT CONTAINS TEST,TEST1,TEST2

1 Like

@Vijay_RPA You should use OR, like “OR (SUBJECT TEST) (SUBJECT TEST1)”. You have all the information in the Official documentation and in the RFC 3501 - INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1 link that I’ve provided (also available in documentation)

Thank you I used OR as out of string … Will check :slight_smile:

Tested with OR Conditions @ovidiuponoran . It is working fine for me with one But attempting with two conditions showing bad response … can you please find below screenshots . OR Condition there in logic which is not in screeshot



@Vijay_RPA there should be a space character in between the parentheses, i.e. OR (SUBJECT TEST) (SUBJECT TEST1) instead of OR (SUBJECT TEST)(SUBJECT TEST1).

1 Like

Working Thank you :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.