Help!

Add x-header using CDO 1.21

 
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Program Add-Ins RSS
Next:  OL03: Adv Opts Add-In Manager/COM Add-Ins disable..  
Author Message
Bharathi Harshavardhan
External


Since: Jun 28, 2007
Posts: 2



PostPosted: Thu Jun 28, 2007 11:05 am    Post subject: Add x-header using CDO 1.21
Archived from groups: microsoft>public>outlook>program_addins (more info?)


Hi,

I have a requirement where i need to store some information into the x-
header of an outlook email.

I am using Outlook 2003 and Visual Studio 2005(C#). I have created a
shared Addin project.

I got to know that x-headers cannot be created using Outlook Object
Model. I want to use CDO 1.21 for this purpose.

Could anyone please assist me how to add x-header to an outlook email
using CDO1.21.

Thanks in Advance
Bharathi
Back to top
Ken Slovak - [MVP - Outlo
External


Since: Oct 17, 2003
Posts: 3405



PostPosted: Thu Jun 28, 2007 11:05 am    Post subject: Re: Add x-header using CDO 1.21 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

You really should not be using CDO 1.21 from C# or any other .NET language.
Neither CDO nor Extended MAPI is supported in .NET code at all and while it
may work most of the time things will fail, usually at a client site and no
one will be able to support you at all.

// toAdd = x-header to add to mail item.
// ID = MailItem.EntryID, item must be saved to have an ID.
// StoreID is the EntryID of the Store where the item is located. Use
item.Parent.StoreID to get it.
private void AddHeader(string toAdd, string ID, string StoreID)
{
// see http://support.microsoft.com/kb/195656 for how to convert
// a MAPI tag to a CDO tag
const string propSet = "8603020000000000C000000000000046";

MAPI.Session cdo = new MAPI.Session;
cdo.Logon "", "", false, false, missing, missing, missing;
MAPI.Message item = (MAPI.Message)cdo.GetMessage(ID, StoreID);
MAPI.Fields fields = (MAPI.Fields)item.Fields;
MAPI.Field header = fields.Add("MyHeader", 8, toAdd, propSet);
item.Update(true, true);
}

After that, since Outlook doesn't really know about changes made to an item
outside of its scope you should do something like this to make it aware of
the change:

Outlook.MailItem mail.Subject = mail.Subject;
mail.Save;

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Bharathi Harshavardhan" wrote in message

> Hi,
>
> I have a requirement where i need to store some information into the x-
> header of an outlook email.
>
> I am using Outlook 2003 and Visual Studio 2005(C#). I have created a
> shared Addin project.
>
> I got to know that x-headers cannot be created using Outlook Object
> Model. I want to use CDO 1.21 for this purpose.
>
> Could anyone please assist me how to add x-header to an outlook email
> using CDO1.21.
>
> Thanks in Advance
> Bharathi
>
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Program Add-Ins All times are: Eastern Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum