2

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?

5
  • Try adding dobule backslash for all the items of the path. Commented Apr 4, 2016 at 11:03
  • Try to use these backslashes : / Commented Apr 4, 2016 at 11:09
  • Using "\\" or "/" for all of them doesn't help. I printed the string and it prints as: C:\Users\User\Desktop\Python\ThisisaTestTitle.pdf Commented Apr 4, 2016 at 11:14
  • Try using an r in front of the path r"C://Users//User//Desktop//Python//ThisisaTestTitle.pdf". Commented Apr 4, 2016 at 12:21
  • That also doesn't help Commented Apr 4, 2016 at 13:12

1 Answer 1

8

The "add" should be capitalized: Msg.Attachments.Add(...

Sign up to request clarification or add additional context in comments.

1 Comment

Of course that's all it is.... Here is my working final code setup: Msg.Attachments.Add(Source = "{}\\{}".format(os.getcwd(),pdfname))

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.