Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从*.msg文件[Java]接收电子邮件地址,而不是带有POI的名称_Java_Email_Apache Poi_Msg_Read Data - Fatal编程技术网

从*.msg文件[Java]接收电子邮件地址,而不是带有POI的名称

从*.msg文件[Java]接收电子邮件地址,而不是带有POI的名称,java,email,apache-poi,msg,read-data,Java,Email,Apache Poi,Msg,Read Data,我编写了一个小型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 dis

我编写了一个小型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()的第一个元素来获取返回路径,即“from”的电子邮件地址。有点脏。。。所以我的问题还有待回答;)

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

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

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

我发现这是关于这个问题的讨论。看起来Apache的库很快就会有一个黑客解决方案。