Click here to Skip to main content
13,260,019 members (49,368 online)
Rate this:
 
Please Sign up or sign in to vote.
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?
Posted 26-Jan-16 7:24am
Thornik2.3K
Updated 26-Jan-16 7:45am
v3

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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

Const PR_TRANSPORT_MESSAGE_HEADERS = "http://schemas.microsoft.com/mapi/proptag/0x007D001E"
 
Outlook.PropertyAccessor olPA = olkMsg.PropertyAccessor;
String Header = olPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS);
  Permalink  
Comments
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web03 | 2.8.171114.1 | Last Updated 26 Jan 2016
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100