admin管理员组文章数量:1122832
I want to send automated mails from my outlook to some email addresses using python win32com.
This is the code I am using -
def Emailer(text, subject, recipient):
import win32com.client as win32
import os
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = recipient
cc_address = '[email protected]'
# mail.CC = f"<{cc_address.strip()}>"
mail.Subject = subject
mail.HtmlBody = text
print("To:", mail.To)
###
# attachment1 = os.getcwd() +"\\file.ini"
#
# mail.Attachments.Add(attachment1)
###
mail.Send()
MailSubject= "Auto test mail"
MailInput= " This is test mail"
MailAdress="[email protected];[email protected]"
Emailer(MailInput, MailSubject, MailAdress )
I am able to send the mail successfully when mail.CC
is not defined / commented.
But when I add recipients in mail.CC
. I am getting the following error -
2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', 'The object does not support this method.', None, 0, -2147352567), None)
Is there any other way of adding CC recipients?
本文标签: emailError received when CC recipients are added in win32com using pythonStack Overflow
版权声明:本文标题:email - Error received when CC recipients are added in win32com using python - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283527a1926997.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论