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.

Lee

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.

Code:


MailMessage eml = new MailMessage("from@domain.com", "to@domain.com", "Subject", "Body");
eml.isDraft(false);

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);
message.setProperty(property);

message.save("1.msg");

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.

Lee

Hi Lee,


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