Get outlook message NOT messeges

Is there any way to get only the first outlook message that fits a filtering criteria? For instance let’s say I have 3 emails in my inbox. I want it to search the subject lines until it finds my filtering criteria. After it finds the first one I want it to stop looking for other messeges. So if my subject line was found in email 2 it wouldn’t go look at email 3. Email 3 would also have the correct filtering but I want to process that on the second run of the automation

@Asanka,

In the Get Outlook Mail Messages activity set the Top Property to 1,then it will get one mail alone.

Filter you need to pass based on your conditions.

Yah that’s possible
In Get Outlook Mail Activity along the property Filter set the filter like this
“[Subject] = ‘your subject’ “
Or
If we want to check any word like kind of condition then use this expression
“SQL=urn:schemas:httpmail:subject like ‘%your keyword%’ “

Then in the TOPproperty set as 0 so that it will first filter the mail with the subject condition specified and then from that it will take the first mail alone

That’s all you are done
Hope this would help you
Cheers @Asanka

Hey, I try it and it does not seem to work. Is there something wrong with my syntax? this is what I am typing:

“[Subject]= test”

Also, is it possible to use contains instead of equals?

you were almost done
the expression be like this
“[Subject] = ‘test’ ”
yah to check like contains or not
the expression be like this

"SQL=urn:schemas:httpmail:subject like ‘%test%’ "

Cheers @Asanka

Just tried the sql one and i got an error

19.4.4+Branch.support/v2019.4.Sha.6d308c7f5a32b559373887ae421ce7eaec8f8d24

Source: Get Outlook Mail Messages

Message: Condition is not valid.

Exception Type: System.Runtime.InteropServices.COMException

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.Runtime.InteropServices.COMException: Condition is not valid.
at UiPath.Mail.Activities.GetMailActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

I also tried with with just using Test and it does not work. Here is a pic:

Hi
your filter condition looks fine
but here the TOP property is set as 0
image

thats why we dont get any mail
–so mention some value more than 0 so that it will fetch some mail from the inbox

Cheers @Asanka

Hey,

I thought you told me to set the top property to 0.

I tried changing that number but it still does not work…

Okay I actually figured it out. I used a different approach:

I just used the break activity to jump out of the foreach after it found the first one.

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