How to add Custom Header Mail Item

R

racniro

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;

}
 
K

Ken Slovak - [MVP - Outlook]

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top