We’re using Microsoft Office 365, Get Mail activity to retrieve the mails from an account created specifically for the robots.
Each robot handles specific mails based on the mails’s titles.
There’s Query property of Get Mail activity that allows us to filter the retrieved mails.
The issue that this property only accepts “eq” (equal) operator. For example, using the following value of the property works fine:
“subject eq ‘Progress AP Invoice of APR-2019’”
Trying to use operators like “contains”/“startswith” instead of eq, all fails.
We need to be able to do something like “subject contains ‘Progress AP Invoice’” or “subject startswith ‘Progress AP Invoice’”.
I know I can retrieve all the mails and later one check the subject if contains the value we need or not. But this solution we require that all robots to process all mails and all the actual steps of the robot to do will be basically inside if condition.
So, is there a way to use any operator to check substring of the mail subject using the Query property.
Your other workaround is just checking on each email if it satisfy your condition using if activity which is not the best option when your mail list is large.
Thanks @Emman_Pelayo for your reply.
I’ve checked it before, but the list doesn’t include operator that would solve my issue.
I was hoping there may be around around using VB.Net script for something like that.
I haven’t tried connecting to office365 yet but you can try to convert the Office365Message return type of the get mail activity to a datatable/List first. With that, you can easily use vb.net script for your mail list.
What is the query when we want to filter emails with subject that contains a keyword/
For example : I want to filter all emails that contains subject = ‘Test’
Mail 1 subject : ‘Test1’
Mail 2 subject : ‘Test2’
Mail 3 subject : ‘Test3’
“subject eq '”+TextInput+“'” is not working.
Getting BadRequest error.
What is the correct format to use for Query in Get Mail activity (Microsoft Office 365 scope)?
I’m having a problem specifically using “endsWith” to qualify the query.
When I try to use “endsWith”, I get the following error:
Get Mail - get email from EBI: Code: ErrorInvalidUrlQueryFilter
Message: The query filter contains one or more invalid nodes.
I can substitute “contains” or “startsWith” and I don’t get an error.
The query is:
"ReceivedDateTime gt “+dtCurrent.toString(“yyyy-MM-dd”) + " and startsWith(Subject, ‘The Job: EMAPMEND’) and endsWith(Subject, ‘completed with warnings’)”
I’ll use “contains” to get around the issue for now, but would appreciate someone looking into the issue.