Hi,
using HtmlFormatOptions.WriteHeader
to save an email as html results in invalid html. The opening html element is somewhere inside the body element followed by a second head and body element etc.
Please use the following java code to reproduce the issue:
// Create a new instance of MailMessage class
MailMessage message = new MailMessage();
// Set subject of the message
message.setSubject( "New message created by Aspose.Email for Java" );
// Set body
message.setBody( "Example message body" );
// Set sender information
message.setFrom( new MailAddress( "from@domain.com", "Sender Name", false ) );
// Add TO recipient
message.getTo().addMailAddress( new MailAddress( "to1@domain.com", "Recipient 1", false ) );
ByteArrayOutputStream bytearrayoutputStream = new ByteArrayOutputStream();
HtmlSaveOptions options = SaveOptions.getDefaultHtml();
options.setEmbedResources( true );
options.setHtmlFormatOptions( HtmlFormatOptions.WriteHeader | HtmlFormatOptions.WriteCompleteEmailAddress );
message.save( bytearrayoutputStream, options );
System.out.println( bytearrayoutputStream.toString( StandardCharsets.UTF_8.name() ) );
Please find attached the expected and the generated html.
html.zip (3.2 KB)
Regards,
Michael