From address extraction doesn't return the email address

When I drag and drop a message (.msg) to the desktop and then try to parse it I get the LDAP reference instead of the email address


message.getFrom().getAddress() returns something like /O=…/OU=…/

This doesn’t occur if I don’t use Exchange.
Is there any way to extract the sender email address?

Thanks,
Mariusz

Hi Mariusz,

Email address representation in this format is a well known issue with Microsoft Outlook that can be caused due to a number of reasons, the typical is incorrect configuration of Exchange Server. It is not a limitation at Aspose.Email end but an issue related to email retrieval from Exchange server, and hence, Aspose.Email can not help in this regard.

Thanks for the explanation. I found another issue. If you try to open/read some msg file where there is a Sender with that LDAP name instead of the email address, Aspose.Email return null from message.getFrom() although I can see the sender when I open the msg file in Outlook or any MSG Viewer. It should return at least the sender name. An example file can be provided.

Hi Mariusz,


Thanks for writing back again.

Please send us the sample file as it will help us to analyze the issue and provide assistance as soon as possible.

Kashif,


I sent you a private message with the example.

Thanks again for your help.

Regards,
Mariusz

Hi Mariusz,


Thank you for providing the sample file.

I have analyzed your provided file with both Outlook spy and a third party tool, Aid4Mail, and both showed that the sender address is not available in your sample message file. You can test it by using either of these tools.

Outlook spy shows that the message is missing PidTagSenderEmailAddress_W property that contains the sender’s email address. Hence, Aspose.Email can’t retrieve this email address as well.

Using Aid4Mail, you can extract the address entries in the message file, which doesn’t return any email address. In addition, if you convert your message to EML using Aspose or the mentioned utility, you will notice that the sender’s email address is not available as it is missing from the sample message.

Please feel free to write to us in case you have any query/inquiry related to Aspose.Email. We’ll be glad to assist you further.

If I open that message with Outlook or with Message Viewer Lite or MSG Viewer tool I can see the recipient name and the LDAP info. Is there at least a way to extract the sender name and not the email address?

I can send you some screenshot if you want, but if I’m able to see the sender name and the Exchance/LDAP name in different viewers, is there a way to extract that with Apose.Email? This is what the users have in their Sent Items box when connected to Exchange server. Without Exchange it works fine, the email address is correctly saved in the MSG message.

I run OutlookSpy and I can see there is SenderName and SenderEmailAddress property in the message, isn’t that enough?

Hi,

The Sender Name information is available in your sent message sample, and you can retrieve it as follow:

MapiMessage msg = MapiMessage.fromFile("EMAIL_472338\RE_
Blueprint Folders Cleanup.msg");
System.out.println(msg.getSenderName());
System.out.println(msg.getProperties().get(MapiPropertyTag.PR_SENDER_NAME_W).toString());

The sender’s email address is not available at my end in smtp format. If you are drag and dropping a message from the “Sent Items” of Outlook, then it is a known problem. As a workaround, you can extract this information by either using Directory Services or Outlook Object Model. Attached to my reply is a sample application for your reference that uses the Outlook Object Model. Please note, to successfully execute the sample application the Outlook should be necessarily connected to Exchange Server and the message sender should be the user of this Exchange.

Thank you for your help!

But if there is a sender attribute set why is it not accessible in the standard getFrom() API? I will use both APIs to read it but I think that this “if” should be rather on the Apose.Email side, is it something you can log as an enhancement request?

There is another issue I found - if I use MapiMessage.fromFile, the getSenderName() returns the correct result, but if I use MapiMessage.fromMailMessage, then it returns null, is it it expected behavior?

Thanks again for your help,
Regards,
Mariusz

Hi Mariusz,

The Sender information is normally the same as the From information. However, there is a difference between these two sets of information as you can have a look from this LINK. Also, the MailMessage class doesn’t support Exchange format address and that is why it returns null in case of MailMessage. For MSG file processing, we recommend to use MapiMessage as it loads the complete set of MapiProperties.