Click here to Skip to main content
15,746,973 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hello, guys!
I cannot do simple stuff: get header of email! I wrote VSTO add-in in C# (VS2015) to target Outlook 2013. I can retrieve current message (and I have in hands MailItem object), but it has nothing corresponding to the raw header! I have a few "preparsed" fields inside MailItem interface, but they are useless - I need "Received-SPF" header!
MS again counts a whole world as stupids and "helps" us with ugliest solution they could create! Instead of providing simple Dictionary<string, string> they made "common used headers" as fields - whoa! And these dumbs study us how to program.... nonsense!

So short question: how to get a whole header from message?
Updated 26-Jan-16 6:45am

1 solution

You can access the properties of each mail item via the propertyaccessor like this:


Outlook.PropertyAccessor olPA = olkMsg.PropertyAccessor;
String Header = olPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS);
Share this answer
Thornik 26-Jan-16 15:37pm    
Wizard, thanks!! I met this solution before, but didn't pay attention to such clumsy code. And it's really what MS "architected"!! *face of russian Lavrov*
NightWizzard 26-Jan-16 16:03pm    
Yeah, seems to be a bit uncomfortable on first sight, but works fine. You can access nearly all informations about mails and other items, that aren't provided by high-level API. I started with an Outlook addin some years ago and made use of PA's for several infos like SMTP formated addresses of all mail recipients and so on. MS API's sometimes appear worse but wait until you face API's of other software (e.g. Tobit) and you'll praise it! :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900