SampleFile.zip (5.8 KB)
Aspose Team,
We use the Aspose Email java package to get email addresses, and found out that it fails to get the original address for some msg file.
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 are 22.6 and 23.9.
Note that with version 22.6 we used the getFrom method to get MailAddress, and we use the method getSender to get MailAddress with version 23.9 because you fixed an issue with the From and Sender MIME headers (23.5 Aspose.Email version) (see Aspose Email From value has changed with java version upgrade - #6 by jmuth).
import com.aspose.email.*;
public class EmailAddress_25 {
public static void main(String[] args) {
try {
new com.aspose.pdf.License().setLicense("/home/ubuntu/QmulusWorker/required/Aspose.Total.Java.lic");
String path = "/home/ubuntu/testdirs/emailaddress_25/RIJ.PC.00000003.msg";
MsgLoadOptions mlo = new MsgLoadOptions();
mlo.setKeepOriginalEmailAddresses(false);
MailMessage mailMessage = MailMessage.load(path, mlo);
MailAddress mailAddress = mailMessage.getSender(); // for 23.9
// MailAddress mailAddress = mailMessage.getFrom(); // for 22.6
String displayName = mailAddress.getDisplayName();
String address = mailAddress.getAddress();
String originalAddress = mailAddress.getOriginalAddressString();
System.out.println("displayName = " + displayName);
System.out.println("address = " + address);
System.out.println("originalAddress = " + originalAddress);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Following is the result with version 22.6:
displayName = Cyndy Foulkrod
address =
originalAddress = /O=INRS/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=CFOULKRO
And following is the result with version 23.9:
displayName = Cyndy Foulkrod
address =
originalAddress =