将Outlook项目(.msg文件)作为附件添加到已发送的Outlook电子邮件中时,文件名返回为null [英] Filename is returned as null when an outlook item (.msg file) is added as attachment to an outlook email sent

查看:440
本文介绍了将Outlook项目(.msg文件)作为附件添加到已发送的Outlook电子邮件中时,文件名返回为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从Outlook发送带有Outlook项目(.msg文件为附件)的电子邮件时,方法getFileName()(用于获取与正文部分关联的文件名)的返回值为null. .我还尝试使用DataHandler()getName(),但仍将值设为null.

如何处理将Outlook项目(.msg文件)作为附件的情况?

PS :我能够检索其他所有附件(.png,.doc,.pdf等)的文件名,仅使用.msg附件会遇到麻烦.

任何建议将不胜感激.

谢谢.

解决方案

您观察到的内容对从Outlook发送的邮件有效.让我们看看Outlook中包含常规附件的邮件的来源.例如,附件的标题看起来像...

Content-Type: image/png; name="404.png"
Content-Disposition: attachment; filename="404.png"; size=30193; creation-date="Wed, 25 Jul 2018 13:44:01 GMT"; modification-date="Wed, 25 Jul 2018 13:44:01 GMT"
Content-Transfer-Encoding: base64

已附加图像的filename字段,当您尝试检索它时,它将返回404.png.

现在让我们看一下其中带有附件.msg附件的消息的来源.例如,这看起来就像...

Content-Type: message/rfc822
Content-Disposition: attachment; creation-date="Wed, 25 Jul 2018 13:40:28 GMT"; modification-date="Wed, 25 Jul 2018 13:40:28 GMT"

如您所见,没有为该类型的附件指定filename,当您尝试检索它时,它将返回null.

该建议非常明显...处理附件时,请查看Content-Type,如果这是没有名称的嵌入式消息,则可以随意设置.例如,Gmail会在附件列表中显示"noname".

I'm getting null as the return value for the method getFileName() (which is used to get the filename associated with the body part) when I send an email from Outlook with Outlook item (.msg file as an attachment). I also tried using the getName() of DataHandler() but still getting the value as null.

How to handle this scenario of having outlook item (.msg file) as an attachment?

PS: I was able to retrieve the file name for every other attachment (.png, .doc, .pdf etc.), I'm facing trouble only with .msg attachment.

Any suggestions would be appreciated.

Thanks in advance.

解决方案

What you observe is valid for message sent from Outlook. Let's see the source of the message sent from Outlook when it contain regular attachment. For example the header of the attachment would look like ...

Content-Type: image/png; name="404.png"
Content-Disposition: attachment; filename="404.png"; size=30193; creation-date="Wed, 25 Jul 2018 13:44:01 GMT"; modification-date="Wed, 25 Jul 2018 13:44:01 GMT"
Content-Transfer-Encoding: base64

The filename field is completed for attached image and when you would try to retrieve it it would return 404.png.

Now let's look at the source of the message with attached .msg attachment inside. This for example would loooks like ...

Content-Type: message/rfc822
Content-Disposition: attachment; creation-date="Wed, 25 Jul 2018 13:40:28 GMT"; modification-date="Wed, 25 Jul 2018 13:40:28 GMT"

As you see there is no filename specified for this type of attachment and when you would try to retrieve it it would return null.

The suggestion is very obvious ... When you handling attachment take a look on Content-Type and if this is embedded message which doesn't have the name, just set whatever you like. For example Gmail would display "noname" in attachments list.

这篇关于将Outlook项目(.msg文件)作为附件添加到已发送的Outlook电子邮件中时,文件名返回为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆