Outlook email filters with variable

Hello @Palaniyappan
Please see the locked form response below for solution you offered for GetOutlookMessages filter:

For this
if we are using GET OUTLOOK MAIL ACTIVITY then we can directly set the filter in FILTER PROPERTY itself like this
"[Subject] = ‘your string’"
of
"@SQL=urn:schemas:httpmail:subject like ‘%your string%’ "

My question is how would you correct this expression to reference a variable (strBody), which is mail.body.tostring?

Thank you!

image image

@D_Tee Can you try this Filter and check if it works :

“@SQL=(”“urn:schemas:httpmail:textdescription”" LIKE ‘%"&strBody &"%’)"

Thank you for the quick response superman. Unfortunately, same issue of cannot parse condition, this time error at "@SQL=(((“urn:schemas:httpmail:textdescri…”.

@D_Tee Ok. In that case Can you try this expression using Assign Activity :

msgs = msgs.Where(Function(x)x.Body.ToLower.Contains(strBody.ToLower)).ToList

Where msgs is the Output of Get Outlook Mail Messages Activity.

1 Like

Thanks for the prompt response.
I am confused by the assign activity. Is this intended to be prior to the get outlook messages step to replace the need for filter? Do I then delete the filter mentioned above?

@D_Tee You need to use this after the Get Outlook Mail Messages Activity, without Filter property mentioned.

“@SQL=urn:schemas:httpmail:subject like ‘%XXX%’”

you can replace the XXX to your variable