Python发送Excel附件会损坏文件

2024-09-24 04:30:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用ezgmail库发送一封电子邮件,并附上一个Excel文件

我可以发送带有附件Excel文件的电子邮件,但当我从发送的电子邮件中打开Excel文件时,由于某种原因,它似乎已损坏,因为我收到以下消息:

We found a problem with some content in 'attached_file.xlsx'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.

当我单击“是”时,我得到:

Excel cannot open the file 'attached_file.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.

我附加的excel文件可以从我的桌面打开,或者如果我手动通过电子邮件发送,也可以打开。只有在通过利用ezgmail的python脚本通过电子邮件发送后,我才会收到这些提示。有人有想法吗


Tags: 文件ofthetoyouformat电子邮件as