Python imaplib从gmail获取附件(pdf),但给出了.dat文件

时间:2018-06-19 16:03:07

标签: python email imaplib

对不起,我的英语。我有一个奇怪的情况。在gmail中,我在一个线程中有2封邮件。例如

enter image description here

我要在控制台中输出邮件中的所有附件名称。例如:

'Value'

在控制台中:

1封邮件

                    for part in mail.walk():
                        print(str(part.get_content_maintype()))
                        filename_orig = str(part.get_filename())
                        print(filename_orig)

在此邮件中,我们可以看到名称为multipart None text None application winmail.dat 的附件。我不明白为什么吗?在这封邮件中,我有pdf文件

2封邮件

winmail.dat

1封邮件中的原始邮件部分:

multipart
None
multipart
None
text
None
text
None
application
252164_2018-06-01.pdf

2封邮件中的原始邮件部分:

--_000_HE1P190MB0492C79D45A6F6F1B40ECC86B8670HE1P190MB0492EURP_
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64

DQo=
--_000_HE1P190MB0492C79D45A6F6F1B40ECC86B8670HE1P190MB0492EURP_
Content-Disposition: attachment; filename="winmail.dat"
Content-Transfer-Encoding: base64
Content-Type: application/ms-tnef; name="winmail.dat"




--_000_HE1P190MB0492C79D45A6F6F1B40ECC86B8670HE1P190MB0492EURP_--

0 个答案:

没有答案