We recently updated from Aspose Email (Java) 3.6.0 to 3.7.1. After the upgrade, the following code block no longer sets the Sender field properly in the PST file after being imported into Outlook. To be specific, this is the sender as it appears in the message list - if you click on a particular message, the sender e-mail address shows up properly. That is because Outlook checks for the display name on the Sender field, for the value to show in the message list. After the Aspose Email update, the display name of the FromAddress is blank, for the same e-mail input text stream. Did something change in the way MailMessage class loads the display name for the from address with this update? And if so, how can I properly get the display name to load now? Again, I want to emphasize that this code block worked perfectly fine in 3.6.0 (and picked up the display name of the from address as expected). Thanks for any insight.
// emlMessageInputStream is an InputStream containing the text of the e-mail
MailMessage mailMessage = MailMessage.load(emlMessageInputStream, MailMessageLoadOptions.getDefaultEml());
if (StringUtils.isNotEmpty(externalBcc)) {
mailMessage.setBcc(MailAddressCollection.toMailAddressCollection(externalBcc));
}
final MailAddress fromAddr = mailMessage.getFrom();
if (mailMessage.getSender() == null && fromAddr != null) {
// ensure that Sender is set if it’s missing because Outlook insists on it
mailMessage.setSender(fromAddr);
}
MapiMessage mapiMessage = MapiMessage.fromMailMessage(mailMessage, OutlookMessageFormat.Unicode);
// personalStorage is an instance of PersonalStorage, and we want to add the MailMessage to a folder called “Downloaded”
personalStorage.getRootFolder().getSubFolder("Downloaded").addMessage(mapiMessage);