Is it possible to set a null sent date on MapiMessage?

Dear Aspose

We are using Aspose.Email to convert EML messages to the MSG format. We ran into a problem when attempting to convert a draft message, i.e. a message that was never sent and thus does not have the Date header. When we leave the ClientSubmitTime/DeliveryTime on the MapiMessage as null, your library seems to set the sent time to some arbitrary value far in the future when saving to a file.

Is it possible to set the sent time to none when saving a MapiMessage? Alternatively, is there a way to flag the message is a draft (that MS Outlook would recognise as such and indicate to a user viewing the saved MSG file)?

Many thanks
ML

Hello @ml42,

You can set the “Draft” option before MSG conversion

MailMessage eml = MailMessage.load("test.eml");
eml.isDraft(true);
MapiMessage.fromMailMessage(eml).save("test.msg");

or add “MSGFLAG_UNSENT” to MSG after conversion

MapiMessage msg = MapiMessage.load("test.eml");
msg.setMessageFlags(msg.getFlags() | MapiMessageFlags.MSGFLAG_UNSENT);
msg.getProperties().remove(MapiPropertyTag.PR_CLIENT_SUBMIT_TIME);
msg.getProperties().remove(MapiPropertyTag.PR_MESSAGE_DELIVERY_TIME);
msg.save("test.msg");
1 Like

Thank you very much, @sergey.vivsiuk, removing the properties you listed solved our issue.

Thank you for the feedback.