简体   繁体   中英

Adding Attachment to email through Outlook (Python)

I am trying to add a .pdf to an email as an attachment but I keep getting this error:

pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', 'Cannot add the attachment; no data source was provided.', None, 0, -2147352567), None)

The path is correct and the rest of my email code works perfectly using win32com. I have tried adding the other parameters for Attachments.add but the last two are optional.

Msg.Attachments.add(Source = "C:\\Users\User\Desktop\Python\ThisisaTestTitle.pdf", Type=olByValue)

Does anyone have experience with this error?

“add”应该大写: Msg.Attachments.Add(...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM