1

我编写了一个小型 Java 程序,它使用 POI 3.15 从 *.msg 中提取名称、电子邮件地址、主题、正文并将其写入 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.

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

顺便说一句 - 要接收所有“收件人”的电子邮件地址,您可以使用 getRecipientEmailAddress()。

任何建议如何处理它?

提前致谢

编辑:我刚刚注意到您可以使用 getHeaders() 的第一个元素来获取 Return-Path - 这是“from”的电子邮件地址。有点肮脏的方式......所以我的问题还有待回答;)

4

1 回答 1

2

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

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

Chunks mainChunks = msg.getMainChunks();
StringChunk emailFromChunk = mainChunks.getEmailFromChunk();
String emailFrom = emailFromChunk.getValue();
于 2017-10-09T15:30:01.520 回答