+1 vote

It's possible to read custom Headers when a text message is without attachments. But impossible when it has attachments, is it normal ?

by

1 Answer

0 votes
 
Best answer

It is always possible to read any mail header both custom and standard.

Mail.dll mail parser allows access to entire MIME tree of the email message. IMail.Document property returns MIME document representing an email, and its Root property returns top-most MIME entity. It stores all email headers (such as subject and date for example).

You need to use: IMail.Document.Root.Headers collection to access those:

 var eml = imap.GetMessageByUID(uid);
 IMail email = builder.CreateFromEml(eml);

 // Get custom header:
 string header = email.Document.Root.Headers["x-spam"];
 Console.WriteLine("x-spam: {0}", header);
by (301k points)
...