Convert Email to Pdf - replyTo header doesn't appear

Hi,

In my Java code, I have MailMessage object. Although it consists of “reply-To” header, I can not see this header in converted Pdf file. I see only from, sent, subject, to, message and signature.

How can I add reply-to email address to the pdf file?

MhtMessageFormatter class doesnt have setReplytoFormat like other formats.

Thanks in advance.

Osman

Hello @osmanolgun,

Thank you for being interested in our product.

Could you please provide a code sample to investigate your case?

Thanks in advance.

Hi @margarita.samodurova

Thank you for your reply.Here is a sample code :

MailMessage document;

MhtMessageFormatter msgFormatter = new MhtMessageFormatter();

msgFormatter.setFromFormat(msgFormatter.getFromFormat().replace(“From”, “Kimden”));
msgFormatter.setSentFormat(msgFormatter.getSentFormat().replace(“Sent:”, “Tarih:”));
msgFormatter.setToFormat(msgFormatter.getToFormat().replace(“To”, “Kime”));
msgFormatter.format(this.document);

this.document.save(tmpStream, MessageFormat.getMht(), MailMessageSaveOptions.WriteOutlineAttachmentsToMht);

Hello @osmanolgun,

Your issue is taken for investigation. We’ll contact you as soon as we have results.

Thanks for reporting your case.

Hello @sergey.vivsiuk

I have also controlled with Aspose Email Version 23.1
I couldn’t see either.

MhtSaveOptions so = new MhtSaveOptions();
so.getFormatTemplates().set_Item(MhtTemplateName.FROM, so.getFormatTemplates().get_Item(MhtTemplateName.FROM).replace(“From”, “Gonderici”));

Can I add this Header self manually?

@osmanolgun,

Could you check this code sample to customize the MHT output:

MailMessage document;

MhtSaveOptions saveOptions = new MhtSaveOptions();

saveOptions.getRenderingHeaders().add("From");
saveOptions.getRenderingHeaders().add("To");
saveOptions.getRenderingHeaders().add("Sent");
saveOptions.getRenderingHeaders().add("Subject");
saveOptions.getRenderingHeaders().add("Reply-To");

saveOptions.getFormatTemplates().set_Item("From", "<span class='headerLineTitle'>Kimden:</span><span class='headerLineText'>{0}</span><br/>");
saveOptions.getFormatTemplates().set_Item("Reply-To", "<span class='headerLineTitle'>My custom Reply To:</span><span class='headerLineText'>{0}</span><br/>");

document.save("test.mhtml", saveOptions);

@sergey.vivsiuk

I have tried but it didn’t work. I use Aspose Mail Version 23.1.
I can only see the message of email. The other parts are not converted. Even from, subject, to etc.

My old code is from Version 6.0. it works partly without reply-to header.
MailMessage document;
MhtMessageFormatter msgFormatter = new MhtMessageFormatter();
msgFormatter.setFromFormat(msgFormatter.getFromFormat().replace(“From”, “Kimden”));
msgFormatter.setSentFormat(msgFormatter.getSentFormat().replace(“Sent:”, “Tarih:”));
msgFormatter.setToFormat(msgFormatter.getToFormat().replace(“To”, “Kime”));
msgFormatter.format(this.document);

this.document.save(tmpStream, MessageFormat.getMht(), MailMessageSaveOptions.WriteOutlineAttachmentsToMht);

@sergey.vivsiuk
@margarita.samodurova

I have managed to solve the problem with the Aspose.Email Version 23.5

saveOptions.getRenderingHeaders().add(“Reply-To”); has worked.

I have seen that “custom header convert to MHT” was solved with Version 23.5

Thank you very much for your help and support.

Hi @osmanolgun,

We’re happy your issue has been resolved.

If you ever have any other questions, please, feel free to ask.