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 » Outlook - General Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to add Custom Header Mail Item



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 3rd 06, 03:04 PM posted to microsoft.public.outlook
[email protected]
external usenet poster
 
Posts: 1
Default How to add Custom Header Mail Item

I can not add the custom headers. It runs without giving any errors.
But it did not change the header. If is some thing wrong with my C#
code



Please have a look at following code



"x-test-header" header is not added to the email





1 Type t = Type.GetTypeFromProgID("Redemption.SafeMailItem");


2 Redemption.SafeMailItem sitem = (Redemption.SafeMailItem)
Activator.CreateInstance(t);

3 sitem.Item = this.myMailItem;

4 int i =
sitem.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}",
"x-test-header");

5 sitem.set_Fields(i,"hello");

6 SetPropValue(sitem, "Subject", "Testing Redemption");

7 sitem.Send();





Please see the line number 4 . I m not sure abut it , because in the
vb6 code it is the 8 bit string as to my knowledge . But I do not know
the logic behind it . so how we are going to deal with this in c#.



Can you help me regarding this



This is the method I used for the change the subject field



private static void SetPropValue(object item, string
propertyName,

object propertyValue)

{

try

{

object[] args = new Object[1];

args[0] = propertyValue;

Type type = item.GetType();

type.InvokeMember(

propertyName,

BindingFlags.Public |
BindingFlags.SetField |

BindingFlags.SetProperty,

null,

item,

args);

}

catch (SystemException ex)

{

Console.WriteLine(

string.Format(

"SetPropValue for {0} Exception:
{1} ",

propertyName, ex.Message));

}

return;

}

  #2  
Old April 3rd 06, 03:35 PM posted to microsoft.public.outlook
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to add Custom Header Mail Item

Questions like this are best posted to one of the Outlook programming
groups.

When you get a MAPI property using GetIDsFromNames you must not only supply
the 2 arguments you supplied but you also must OR the result with the type
of MAPI property (ie. PT_STRING8 in this case).

So you must OR your int result with PT_STRING8 (0x1E).

--
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


wrote in message
oups.com...
I can not add the custom headers. It runs without giving any errors.
But it did not change the header. If is some thing wrong with my C#
code



Please have a look at following code



"x-test-header" header is not added to the email





1 Type t = Type.GetTypeFromProgID("Redemption.SafeMailItem");


2 Redemption.SafeMailItem sitem = (Redemption.SafeMailItem)
Activator.CreateInstance(t);

3 sitem.Item = this.myMailItem;

4 int i =
sitem.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}",
"x-test-header");

5 sitem.set_Fields(i,"hello");

6 SetPropValue(sitem, "Subject", "Testing Redemption");

7 sitem.Send();





Please see the line number 4 . I m not sure abut it , because in the
vb6 code it is the 8 bit string as to my knowledge . But I do not know
the logic behind it . so how we are going to deal with this in c#.



Can you help me regarding this



This is the method I used for the change the subject field



private static void SetPropValue(object item, string
propertyName,

object propertyValue)

{

try

{

object[] args = new Object[1];

args[0] = propertyValue;

Type type = item.GetType();

type.InvokeMember(

propertyName,

BindingFlags.Public |
BindingFlags.SetField |

BindingFlags.SetProperty,

null,

item,

args);

}

catch (SystemException ex)

{

Console.WriteLine(

string.Format(

"SetPropValue for {0} Exception:
{1} ",

propertyName, ex.Message));

}

return;

}


  #3  
Old April 4th 06, 11:45 AM posted to microsoft.public.outlook
racni
external usenet poster
 
Posts: 13
Default How to add Custom Header Mail Item

yes that is true and i can work it now

 




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
Item.Recipients.Add Ian Sweeney Outlook and VBA 5 March 23rd 06 11:27 PM
How do I add an item that isn't an appointment? smags Outlook - Calandaring 1 March 22nd 06 07:35 PM
add toolbar in inspector contact item Irene Outlook and VBA 1 February 24th 06 10:23 PM
How can I change the content of my outlook e mail message header? jggome Outlook - Using Contacts 1 January 26th 06 04:32 AM
Custom Task Item Notification HJC Add-ins for Outlook 1 January 12th 06 03:58 PM


All times are GMT +1. The time now is 09:29 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.