I cant get wildcarts to work on filters in mail messages

Bo Fritzen
October 03, 2016 10:47 ANSWERED
I have been trying to get filters to work in mail messages but at this point I have only been successful with “[Subject] = ‘some text string’”.

What I can’t get to work is using wildcart or anything else f.ex. LIKE, IN, CONTAINS, %, * or [%]

I have been reading what I could find regarding this subject and followed the links to Microsoft’s sites about Jet, I just can’t get it to work.

Could someone please give me an example on a filter that do this:

“[Subject] contains this substring ‘Spam’”

Bo Fritzen

1 Like

Andrzej.Kniola October 03, 2016 11:37
Up, couldn’t get it to work either with all syntax variations I could think of.

Closest thing I’ve made to emulate is to get the emails and iterate over them checking the subject (MailItem.Subject returns a string which you can check with normal string comparisons). While this works, it’s definitely suboptimal.

Bo Fritzen October 04, 2016 10:09
Hi Andrzej,

Thank you for the answer.

Yes, that works - but it would be nice if we could get the filter to work thou :slight_smile:

Alex Vasile October 04, 2016 17:25
Hello,

The Filter property is based on the Find method of the Outlook Interop API:

As the documentation says, if you are trying to use the Find or Restrict methods with user-defined fields, the fields must be defined in the folder, otherwise an error will occur. “There is no way to perform a “contains” operation. For example, you cannot use Find or Restrict to search for items that have a particular word in the Subject field.”

So the solution Andrzej provided is the best workaround.

1 Like

Andrzej.Kniola October 04, 2016 18:31
Hi Alex,

If it’s built on _items.find, then what is the correct syntax for DASL queries in that property? I can’t figure that out.

Since in C# I can do like this (first example from SO that caught my eye):

And get a result like this:

But when I try anything valid in DASL from UiPathStudio, it throws either a Condition is not valid or Cannot parse errors.

So there must be something specific to your implementation that does not allow valid DASL queries to work correctly.

I mean sure, usual case is to limit to unread and that limits the results greatly for the iteration (if any needed at all, just take them as they come), but still, if the functionality is there, it should work :slight_smile:

PS> If it’s based on Interop.Outlook, why the return type is System.Net.Mail.MailMessage instead of Interop.Outlook.MailItem (which BTW has much more info, f.e. Importance and BodyFormat)?

Regards.

PPS. If someone is wondering why the dates are so old - it’s because I didn’t sort the collection in any way before Find, nor apply any date filters. Either way it’s besides the question.

1 Like

Absolutely,
DASL Queries should get enabled. DASL queries are also generatable from Outlook itself causing less issues using those.

@andrzej.kniola

With Latest UiPath.Mail.Activities Version - 1.1.6361.22988 now supports the DASL queries in Filter property

Regards…!!
Aksh

3 Likes

Hi… Thanks for your suggestion. But still am facing difficulty on how to use contains inside filter. My exact scenario what I was using is “[To] = ‘abc@gmail.com’” and the address in my mailbox is ‘abc@gmail.com’ and not like abc@gmail.com.

Here is an example that worked for me:

I was searching 1 word “Insolvence” anywhere in the subject and used this dasl query into the filter property of Get outlook mail messages activity:

“@SQL=” & Chr(34) & “urn:schemas:httpmail:subject” & Chr(34) & " LIKE ‘%Insolvence%’"

Worked fine for me :slight_smile:

1 Like

I had similar issue. Everywhere they give you you the DASL filter for Subject. But what we need is for other fields as well (like from, to , cc etc). Please have a look at my post here for the solution that worked like a charm for me:

1 Like

Hello,

I have a similar case can you send me a sample flow.

1 Like