We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Encoding and Empty body issue

I think i found a bug lately on mhtml generation.

Here is a test class for reproducing the issue (I used Aspose mail 6.3.0) :

{code}
public static void main(String[] args) throws FileNotFoundException, IOException {

System.out.println(“Start”);

// License management
try (InputStream inputStream = Test.class.getClassLoader().getResourceAsStream(“Aspose.Total.Java.lic”)){
License license = new License();
license.setLicense(inputStream);
} catch (IOException e) {
return;
}

MailMessage newMailMessage = new MailMessage();
newMailMessage.setBodyEncoding(Charset.forName(“EUC-KR”));
newMailMessage.setSubjectEncoding(Charset.forName(“EUC-KR”));
newMailMessage.setSubject(“상기 메일(첨부화일 포함)은 지정된 수신인만을 위한 것이며, 관련 법령에 따라 보호의 대”);
newMailMessage.save(“c:/Tmp/test.msg”);

MailMessage mailMessage = MailMessage.load(“c:/Tmp/test.msg”);

File mhtmlFile = new File(“c:/Tmp/test.mht”);

try (FileOutputStream fileoutputStream = new FileOutputStream(mhtmlFile);){

MhtSaveOptions mhtSaveOptions = SaveOptions.getDefaultMhtml();
mhtSaveOptions.setMailMessageSaveType(MailMessageSaveType.getMHtmlFormat());
mhtSaveOptions.setCheckBodyContentEncoding(true);
mhtSaveOptions.setPreserveOriginalBoundaries(true);
mhtSaveOptions.setMhtFormatOptions(MhtFormatOptions.WriteHeader);

mailMessage.save(fileoutputStream, mhtSaveOptions);
}

mailMessage.setBody(" ");

mhtmlFile = new File(“c:/Tmp/test-with-space-body.mht”);

try (FileOutputStream fileoutputStream = new FileOutputStream(mhtmlFile);){

MhtSaveOptions mhtSaveOptions = SaveOptions.getDefaultMhtml();
mhtSaveOptions.setMailMessageSaveType(MailMessageSaveType.getMHtmlFormat());
mhtSaveOptions.setCheckBodyContentEncoding(true);
mhtSaveOptions.setPreserveOriginalBoundaries(true);
mhtSaveOptions.setMhtFormatOptions(MhtFormatOptions.WriteHeader);

mailMessage.save(fileoutputStream, mhtSaveOptions);
}

System.out.println(“End”);
}
{code}

When you open both mht file with IE (IE8 exactly) or Chrome, the one without space body is unreadable. The difference comes from the addition of meta-tag when body is not empty. The problem is that, with an empty body (also outlook notification case), Sender, recipients or subject fields may not be empty.

jpeg IE8 display attached.

The workaround exists (adding a space body to the message).

Hi Monteils,


Thank you for contacting Aspose support team.

This issue is re-produced and logged under Id: EMAILJAVA-33581 for further investigation by the product team. You will be notified once any update is received in this regard.

The issues you have found earlier (filed as EMAILJAVA-33581) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.