Showing posts with label Email Headers. Show all posts
Showing posts with label Email Headers. Show all posts

Thursday, January 12, 2012

Available Headers in the SPEmailMessage Object

It couldn't find a complete list of email headers for Microsoft.SharePoint.Utilities.SPEmailHeader, so I've compiled one here;

Here's a sample usage that will return the raw email address of the sender...
// emailMessage is of the type SPEmailMessage
string EmailAddress = emailMessage.Headers["Return-Path"].ToString();
// will return "sender@domain.com"

string EmailAddress = emailMessage.Headers["From"].ToString();
// will return "Sender Contact Name <sender@domain.com>"


Ordinal Name Example
1 x-reciever "recipient@domain.com"
2 Received "from IncomingMailServer([IP])..."
3 Received "from IncomingMailServer([IP])..."
4 From "Sender Contact Name <sender@domain.com>"
5 To "Recipient Contact Name <recipient@domain.com>"
6 Subject "Subject Text"
7 Thread-Topic "Topic Text"
8 Thread-Index guid
9 Date ddd, dd mmm yyyyy hh:mm:ss +0000
10 Message-ID "UniqueId@IncomingMailServer"
11 Accept-Language "en-US"
12 Content-Language "en-US"
13 X-MS-Has-Attach "yes" or ""
14 X-MS-TNEF-Correlator ""
15 x-originating-ip "[IP]"
16 Content-Type ??
17 MIME-Version "1.0"
18 Return-Path "sender@domain.com

Here's a handy way to parse out the date...
DateTime sent = DateTime.Parse(emailMessage.Headers["Date"]);