0 votes

Hello,

Is there a way using Expressions to search only mails having an envelope structure To field containing "ONLY" one specific address

Those expressions works for Gmail but not for Outlook :
- HasHeader Expression : Expression.HasHeader("In-Reply-To")
- Not expression : Expression.Not(Expression.From("hotmail"))
- Header Expression

Note : i already asked the question by sending an email using contact page, sorry for repeating, but i think it's here the right place for questions.

by (200 points)

1 Answer

0 votes

I don't think you can build such expression.

Expression.To("address1") 

will match all email that are sent to address1, but will also match all email send to address1 and address2.

You can of course exclude address2:

Expression.And(
    Expression.To("address1"), 
    Expression.Not(Expression.To("address2")))

but I don't think there is a way to match one and only one address.

Those expressions works for Gmail but not for Outlook :
- HasHeader Expression : Expression.HasHeader("In-Reply-To")
- Not expression : Expression.Not(Expression.From("hotmail"))
- Header Expression

Expression.HasHeader("In-Reply-To")

In-Reply-To header is specified in replies, so the receiver can find the original email.

Expression.Not(Expression.From("hotmail"))

Excludes all email sent from addresses or names that contain "hotmail" string.

Expression.Header("header1", "value1")

Matches all emails that have "header1" header and it contains "value1" string

If any of theses don't work in Outlook.com it is Outlook.com's bug.
Mail.dll only sends a query to the server. It is the server that is responsible to perform actual search.

I've just check and:

Expression.HasHeader - doesn't work
Expression.Header - works correctly (whole word match only, case insensitive)
Expression.Not - doesn't work

by (301k points)
edited by
thanks for your detailed response.
Well then i guess, my only option is to
1- "Get Envelopes",
2- remove those i don't need
3- "Get complete messages"

If i may ask another question:
i remarked that requesting Outlook using Imap is slower (10 times for some tests) than Gmail, or Yahoo, Orange, Sfr, ....

Have you ideas:
May be improved?
May be a server slowness?
Or .... ?

thank you again.
GetEnvelopeByUID -or- GetMessageInfoByUID (https://www.limilabs.com/blog/get-email-information-from-imap-fast) should be fast enough.

As for the Outlook slowness - I don't think you can do anything - it's obviously server related.
...