问题
I have my script to send out messages on Outlook via Python win32com.client. I can create the email and format my body but when I try to do newmail.Send()
I am getting an error I cannot figure out.
Below is my code along with the error:
obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = "Subject"
newMail.Body = "Actualemail"
newMail.To = "test@test.com"
newMail.Send()
I get the follow error :
Traceback (most recent call last):
File "<pyshell#105>", line 1, in <module>
newMail.Send()
File "<COMObject CreateItem>", line 2, in Send
pywintypes.com_error: (-2147467260, 'Operation aborted', None, None)
Anyone ever deal with this? Everything else works but the send function
回答1:
I found the issue. For some reason when I displayed the email and then sent it got it working.
回答2:
On
newMail = obj.CreateItem(olMailItem)
Use the type value instead of the type name
Example
newMail = obj.CreateItem(0)
来源:https://stackoverflow.com/questions/59365331/sending-email-with-python-win32com-client-send-error