SampleFile.zip (2.2 KB)
Aspose Team,
We use the Aspose Email java package to get email body from msg and eml, and found out that it fails to get email body from the sample eml (Outlook displays email body).
Following is the sample code and attached is a sample file.
The operating system is Ubuntu 20.04. Java version is 17. Aspose Email java packages is 23.12.
import com.aspose.email.*;
public class GetEmailBody_28 {
public static void main(String[] args) {
String inputMsg = “/home/ubuntu/winshare/00_Sample_Files/EML_No_Body_Bug_829061/T2.EM.00000070.eml”;
try {
new com.aspose.email.License().setLicense(“/home/ubuntu/QmulusWorker/required/Aspose.Total.Java.lic”);
// Do not use the setting
EmlLoadOptions emlLoadOptions = new EmlLoadOptions();
MailMessage mailMessage = MailMessage.load(inputMsg, emlLoadOptions);
MapiMessage mapiMessage = MapiMessage.fromMailMessage(mailMessage, MapiConversionOptions.getUnicodeFormat());
MapiMessage mapiMessage2 = MapiMessage.load(inputMsg);
// Get email body
if(mailMessage.isBodyHtml()){
System.out.println("email body 1 = " + mailMessage.getHtmlBodyText(true));
} else {
System.out.println("email body 2 = " + mailMessage.getBody());
}
System.out.println("email body 3 = " + mapiMessage.getBody());
System.out.println("email body 4 = " + mapiMessage.getBodyHtml());
System.out.println("email body 5 = " + mapiMessage2.getBody());
System.out.println("email body 6 = " + mapiMessage2.getBodyHtml());
mailMessage.close();
mapiMessage.close();
mapiMessage2.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}