We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Setting a new MapiProperty from a string

Hi there,

I am trying to add the content of a string to the mapi property PR_TRANSPORT_MESSAGE_HEADERS (tag 0x007D001E) of a mapimessage

I cannot see how to add this property to the existing properties.

Your advice is much appreciated.


Hi Lee,

This header is set by the transport provider and can be set manually as follow. Please try the following code at your end and share your feedback with us.


MailMessage eml = <span style=“font-size:10.0pt;font-family:Consolas;mso-fareast-font-family:“Times New Roman”;
MailMessage(<span style=“font-size:10.0pt;font-family:Consolas;mso-fareast-font-family:“Times New Roman”;
mso-bidi-font-family:Consolas;color:#2A00FF”>"from@domain.com",<span style=“font-size:10.0pt;
font-family:Consolas;mso-fareast-font-family:“Times New Roman”;mso-bidi-font-family:
Consolas;color:#2A00FF”>"to@domain.com",<span style=“font-size:10.0pt;
font-family:Consolas;mso-fareast-font-family:“Times New Roman”;mso-bidi-font-family:
Consolas;color:#2A00FF”>“Subject”,<span style=“font-size:10.0pt;font-family:Consolas;
mso-fareast-font-family:“Times New Roman”;mso-bidi-font-family:Consolas;
color:#2A00FF”>“Body”);<span style=“font-size:10.0pt;font-family:Consolas;
mso-fareast-font-family:“Times New Roman”;mso-bidi-font-family:Consolas”><o:p></o:p>


MapiMessage message = MapiMessage.fromMailMessage(eml);

String s = "Transport Headers";

byte[] b = s.getBytes(Charset.forName("UTF-8"));

MapiProperty property = new MapiProperty(MapiPropertyTag.PR_TRANSPORT_MESSAGE_HEADERS, b);



Thanks for your reply, it was a useful pointer but this resulted in garbage being saved.

What worked for me was using:-

MapiProperty property = new MapiProperty(MapiPropertyTag.PR_TRANSPORT_MESSAGE_HEADERS, b);
message.setProperty(property, 0, MapiPropertyTag.PR_TRANSPORT_MESSAGE_HEADERS);

Thanks for your assistance.


Hi Lee,

Thank you for providing feedback. Please feel free to write us back if you have any other query related to Aspose.Email.