从 *.msg-file [Java]接收电子邮件地址而不是名称



我写了一个小的java程序,它通过使用poi 3.15从a *.msg提取名称,电子邮件地址,主题,bodytext并将其写入Excel表。

通过阅读Mapimessage API文档,我看到了:

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.

现在,我想从发件人那里获得电子邮件地址,而不是他的存储昵称。

只是顺便说一句 - 用于接收所有"到"的电子邮件address,您可以使用getRecipientemailAddress((。

有什么建议如何处理?

预先感谢

编辑:我只是注意到您可以使用getheaders((的第一个元素来获取返回路径 - 这是"来自"的电子邮件address。有点肮脏的方式...所以我的问题仍然要回答;(

我在以前的版本中不知道,但是在3.17中,您可以从主块获得它。

MAPIMessage msg = new MAPIMessage("email.msg");
Chunks mainChunks = msg.getMainChunks();
StringChunk emailFromChunk = mainChunks.getEmailFromChunk();
String emailFrom = emailFromChunk.getValue();

相关内容

最新更新