A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Add x-header using CDO 1.21



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 28th 07, 01:05 PM posted to microsoft.public.outlook.program_addins
Bharathi Harshavardhan
external usenet poster
 
Posts: 1
Default Add x-header using CDO 1.21

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

  #2  
Old June 28th 07, 03:40 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Add x-header using CDO 1.21

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
ups.com...
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


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Message Header John Lane Outlook and VBA 4 March 28th 07 08:52 PM
2 accounts, one of them using the header of the second steve070 Outlook - Installation 0 November 22nd 06 04:13 AM
Header & Footer David French Outlook - Calandaring 1 August 25th 06 06:45 PM
Header in Outlook Marilyn Outlook - Calandaring 6 July 7th 06 03:43 AM
header print pb Pierre Outlook - General Queries 0 April 13th 06 10:26 AM


All times are GMT +1. The time now is 08:34 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.