Free Support Forum -

MapiAttachment.getDisplayName() does not return multi byte characters


I am using the following code to extract and save attachments in a msg.

MailMessage message = MailMessage.load(inputFile, MessageFormat.getMsg());
MapiMessage mapiMsg = MapiMessage.fromMailMessage(message);
MapiAttachmentCollection collection = mapiMsg.getAttachments();

if(collection != null && collection.size() > 0)
for(int i=0; i< collection.size(); i++)
MapiAttachment attach = (MapiAttachment)collection.get(i);
String attachName = attach.getDisplayName(); //the string here has multi byte characters as ‘?’

I see if the attachment name has multi byte characters the getDisplayName method returns ‘?’ for those characters.

Please find attached the input file to reproduce the issue.

Hi Shyama,

Thank you for using Aspose.Email.

Please modify the line of code:

MapiMessage mapiMsg = MapiMessage.fromMailMessage(message);<o:p></o:p>


MapiMessage mapiMsg = MapiMessage.fromMailMessage(message,OutlookMessageFormat.Unicode);<o:p></o:p>

This will return proper name of the attachments in the email. Please feel free to contact us if you have any query/difficulty. We will be glad to assist you further.