View Single Post
  #2  
Old March 31st 09, 02:17 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default x-header insertion issue

An x-header is created from that MAPI named property only when the item is
sent out. The x-header creation is done after the item leaves Outlook and
goes through the message transport.

So you will never see that x-header in a saved item or even your copy of the
sent item in Sent Items. It will be there only in the received email, and
only then if the email was sent to a recipient outside of an Exchange
organization.

If an email is sent internally within an Exchange organization no x-header
is created because the PR_TRANSPORT_MESSAGE_HEADERS property is never
created. It's also never created on saved items or your copy of a sent item.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Microsoft" wrote in message
...
Hi Ken,

I tried to implement the following code in the ThisAddIn_Startup method on
application startup. The code seems to be working fine and no exception is
thrown on the run time. However, when I go back into the inbox and right
click on option, I couldn't find the 'x-testheader' in the header section.
I have tried out all the possible solutions that I can think of but still
no luck to make it work. Can you please give me some direction on what may
went wrong with the following code? thanks in advance.

foreach (Outlook.MAPIFolder folder in this.Application.Session.Folders)

{

Outlook.MAPIFolder inbox = folder.Folders["Inbox"];

foreach (object o in inbox.Items)

{

Outlook.MailItem mailItem = o as Outlook.MailItem;

if (mailItem != null)

{

// Adding x-header

string xHeaderTag =
"http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/x-testheader";

mailItem.PropertyAccessor.SetProperty(xHeaderTag,
mailItem.EntryID.ToString()); // set entry id value

mailItem.Save();



}

}

}



Cheers,

Kyle



Ads