Basti
Basti

Reputation: 11

Receive Email address instead of Name with POI from *.msg-File [Java]

i wrote a small java programm which extract the names,email address, subject, bodytext from a *.msg by using POI 3.15 and writes it to an excel sheet.

By reading the MAPIMessage API Documentation i saw:

getDisplayFrom() --> Gets the display value of the "FROM" line of the outlook message This is not the actual address that was sent from but the formated display of the user name.

Now i would like to get the email address from sender instead of his stored nickname.

Just btw - for receiving the Emailaddress of all "to"-persons you can use getRecipientEmailAddress().

Any suggestions how to deal with it?

thanks in advance

Edit: I just noticed you can use the first element of getHeaders() to get the Return-Path - which is the emailaddress of "from". kinda dirty way ... so my question is still up to be answered ;)

Upvotes: 1

Views: 1311

Answers (1)

angro
angro

Reputation: 160

I don't know in previous versions, but in 3.17 you can get it from main chunks.

MAPIMessage msg = new MAPIMessage("email.msg");

Chunks mainChunks = msg.getMainChunks();
StringChunk emailFromChunk = mainChunks.getEmailFromChunk();
String emailFrom = emailFromChunk.getValue();

Upvotes: 2

Related Questions