[python-win32] pywintypes.com_error- no data source was provided when sending outlook attachment
Joe
tooke412 at yahoo.com
Sat Mar 19 11:09:34 EDT 2016
Hello,Iam trying to send an email through outlook 2010 on a win 7 64 bit oswith python 2.7 32 bit and win32com 32 bit. I am using the same codeexample found in many Google search results. This chunk of code willrun fine if I rem out the attachment, but once I try adding theattachment, I get an error about 'no data source provided'. Thissame sample of code appears to work fine in many instances, but I'vealso seen this error appear on the net since 2002. I've also changedthe attachment line use this format, and have tried it myself, butno luck#newMail.Attachments.Add('Location', olByValue, 1, 'Description')
I've named changed the name of the attachment every way possible (r'c:\test.txt c:\test.txt c:\\test.txt) and I've placed it in other directories, but still the same error.
Any suggestions
importwin32com.clientolMailItem = 0x0
obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = "I AM SUBJECT!!"
newMail.Body = "I AM IN THE BODY\nSO AM I!!!"
newMail.To = "themail at mail.org"
#newMail.CC = "moreaddresses here"
#newMail.BCC = "aaa"
attachment1 = r'c:\test.txt'
newMail.Attachments.Add(attachment1)
newMail.Send()
pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, 'Microsoft
Outlook', 'Cannot add the attachment; no data source was provided.',
None, 0, -2147352567), None)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20160319/252c4c67/attachment.html>
More information about the python-win32
mailing list