Kufel
Kufel

Reputation: 43

How to add custom internet headers to emails?

Can someone provide how to create and add custom internet headers to the mailItem and how to read them later? I am trying to attach a keyword to every email that is sent so it can be read by another outlook client with the same add-in.

Upvotes: 4

Views: 3102

Answers (1)

Steve Kennedy
Steve Kennedy

Reputation: 5402

Assuming you're writing a Outlook Plugin (based on your tag). Get a Handle on your current mail item (email in draft form)...

// Describes your Custom Header
string  PS_INTERNET_HEADERS = "http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/Custom-Property-Name";

// Sets Your Custom Header
CurrentMailItem.PropertyAccessor.SetProperty(PS_INTERNET_HEADERS, "ValueOfCustomProperty" );

// Reads Your Custom Header
string valueResult = CurrentMailItem.PropertyAccessor.GetProperty(PS_INTERNET_HEADERS);

You might get away something like this:

// Sets Your Custom Header
CurrentMailItem.PropertyAccessor.SetProperty("CustomHeaderName", "ValueOfCustomProperty" );

// Reads Your Custom Header
string valueResult = CurrentMailItem.PropertyAccessor.GetProperty("CustomHeaderName");

Also, check out: https://social.msdn.microsoft.com/Forums/office/en-US/b4218b03-d495-459f-a112-8d4e1e05ad3e/set-custom-headers-to-outlook-mailitem?forum=outlookdev

Upvotes: 7

Related Questions