Free Support Forum -

Invalid HTML using HtmlFormatOptions.WriteHeader



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( "", "Sender Name", false ) );

// Add TO recipient
message.getTo().addMailAddress( new MailAddress( "", "Recipient 1", false ) );	
ByteArrayOutputStream bytearrayoutputStream = new ByteArrayOutputStream();

HtmlSaveOptions options = SaveOptions.getDefaultHtml();

options.setEmbedResources( true );
options.setHtmlFormatOptions( HtmlFormatOptions.WriteHeader | HtmlFormatOptions.WriteCompleteEmailAddress ); bytearrayoutputStream, options );

System.out.println( bytearrayoutputStream.toString( ) );

Please find attached the expected and the generated html. (3.2 KB)




Thank you for contacting Aspose Support.

We were able to reproduce the issue reported by you. We have logged a ticket in our issue tracking system as EMAILJAVA-34468 to investigate this scenario further. We will update you here as soon as additional information is available.


The issues you have found earlier (filed as EMAILJAVA-34468) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by muhammadahmad