NativeViewWithPrizmDoc.zip (121.2 KB)
SampleMsgFiles.zip (66.8 KB)
Aspose Team,
We use the Aspose Email java package to extract body text from msg files, and we found out that the body text has space skipped in phrase “Safe Harbor” for the attached msg sample files. For example, the native view of the sample file v2_01_reply_s3.msg is as shown in the attached image file v2_01_reply_s3.msg.png (viewed with PrizmDoc). Note that the sample msg files fail to open with Outlook and they can be viewed with PrizmDoc. The extracted body text is as follows.
'Current response regarding the SafeHarbor option.
From: Test Sender 1 sender1@example.invalid
Sent: Monday, January 7, 2013 9:15 AM
To: Test Recipient recipient@example.invalid
Subject: Plan Design Options
Historical message 1 discusses the SafeHarbor option.
From: Test Sender 2 sender2@example.invalid
Sent: Monday, January 6, 2013 9:15 AM
To: Test Recipient recipient@example.invalid
Subject: Plan Design Options
Historical message 2 discusses the SafeHarbor option.
’
Note that one of our client has a number of msg files from an email chain, and “Safe Harbor” is extracted as “Safe Harbor” from some of the msg files but extracted as “SafeHarbor” from some other msg files. We do not have such sample file in none-client data.
Following is the sample code. Attached are the sample msg files and two image files for the native view of two of the sample msg files with PrizmDoc .
The operating systems are is Ubuntu 20.04 and Windows 11. Java version is 25. Aspose Email java packages is 26.8.
Sample code:
import com.aspose.email.MailConversionOptions;
import com.aspose.email.MailMessage;
import com.aspose.email.MapiMessage;
import com.aspose.email.MsgLoadOptions;
import static java.util.Objects.*;
public class GetBodyText_38 {
static final String FILE_PATH = “path-to-sample-file”;
public static void main(String[] args) {
setSystemSettings();
MsgLoadOptions msgLoadOptions = new MsgLoadOptions();
msgLoadOptions.setPreserveEmbeddedMessageFormat(true);
msgLoadOptions.setLeaveOpen(true);
try (MapiMessage mapiMsg = MapiMessage.load(FILE_PATH, msgLoadOptions)) {
MailConversionOptions conversionOptions = new MailConversionOptions();
conversionOptions.setAttachmentCidTemplate("cid-{#}");
try (MailMessage mailMsg = mapiMsg.toMailMessage(conversionOptions)) {
System.out.println("Get body text...");
String bodyText = mailMsg.isBodyHtml() ? mailMsg.getHtmlBodyText(true) : mailMsg.getBody();
if (isNull(bodyText)) {
System.out.println("Get body text failed: body text is null");
} else {
System.out.println("Body text: '" + bodyText + "'");
}
}
}
}
private static void setSystemSettings() {
try {
String asposeLicense = "path-to-license-file";
new com.aspose.email.License().setLicense(asposeLicense);
} catch (Exception e) {
System.out.println("Failed to load the license: " + e.getMessage());
System.exit(-1);
}
}
}