0 votes
by (260 points)


We are having problems using the IMAP search against Office 365 (Exchange Server).

The code is very simple. Search parameters are: from and Date. On a second test we try with from ,date and a custom X-Header

e SelectFolder(folder);

String CleanFrom = GetCleanEmail(from);

List<ImapSearchParameter> Params = new List<ImapSearchParameter>();

if (!String.IsNullOrEmpty(CleanFrom))

if ((date.HasValue) && (date.Value.Between(MinDate, MaxDate)))

if (!String.IsNullOrEmpty(sourceId))
   Params.Add(ImapSearchParameter.Header(MailFlockXHeader, sourceId));


ImapMessageCollection List = Imap.Search(ImapListFields.Envelope, Params.ToArray());

In Both cases messages with different from and x-header are returned.

Some Prints of the parameters and results:

The params:

enter image description here

And the Results (The last one is wrong- note the sender and date). The X-Header is different of the param too. The erratic behavior repeats on several searches.

enter image description here

We are doing something wrong or this is an Exchange bug, or a library bug?

Thank you for the support.

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (58.9k points)


I checked your code and found one problem
Searching within custom headers is supported but you will have to Search with ImapListFields.FullHeaders (instead of ImapListFields.Envelope like this):

ImapMessageCollection list = imap.Search(ImapListFields.FullHeaders, pars.ToArray());

ImapListFields.Envelope does only retrieve (from the enum member documentation):

Envelope (date, subject, from, sender, reply-to, to, cc), sequence
number, unique ID, length, flags and received date.

So it means that the "X-MailFlock" header will be ignored during your above Search.

So please try to Search with ImapListFields.FullHeaders as suggested and let me know whether it solves your problem.

by (58.9k points)
In case it does not solve the problem, please create a log of communication as described at http://www.rebex.net/kb/logging/default.aspx and then either post it here, or send it to support@rebex.net. Seeing the actual communication between your IMAP server and Rebex IMAP client, should make it possible for us to help you.