Custom headers gets removed while dowloading DRAFT using MapiMessage.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT)

When I create an email then save as DRAFT status using MapiMessage.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT) and then save this email to file as a .MSG file, reopen and send, I can see the email in my inbox. But the custom headers that I added before saving the draft are somehow getting removed. Is there a way to retain the cutom headers in the draft?

Hello @ranakomal90 ,

Thank you for writing to Aspose. Email support.

We’ll gladly help you with the issue. Can you please share a sample code where you set custom headers?

Thank you.

Hi Margarita, Please fin the code snippet as follows. Using in a Java controller class:

MapiMessage draftFromFile = MapiMessage.fromStream(ABCController.class.getClassLoader().getResourceAsStream(“ABC.msg”));
draftFromFile.setSubject(subject);
draftFromFile.setBodyContent(“Test Email”, BodyContentType.Html);
draftFromFile.getHeaders().add(“X-Custom-Header-Task-Id”, “123456654321”);
draftFromFile.setMessageFlags( MapiMessageFlags.MSGFLAG_UNSENT);
draftFromFile.save(output);
headers.set(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + fileName);

@ranakomal90
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): EMAILNET-41356

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi Alexander,

We have paid license of email-aspose for our organization-wide use. Can you please let me know if it can be priortized?

@ranakomal90 ,

According to our Free Support Policies, all customers get help in turn.

We’re sorry for keeping you wait.

Hi @ranakomal90 ,
We check your case and found that it is not an Aspose.Email problem. When you save a message on disk the headers saved in property PR_TRANSPORT_MESSAGE_HEADERS. Then when you reopen it, the custom header is still present in headers of loaded message. But if you send a message, the mail server can change this property and Aspose.Email cannot influence this in any way.
Please see useful link: EWS, MIME, and the missing Internet message headers | Microsoft Learn