[英]How to send email from python script
i have an email function to send multiple emails for that i need to call that function and i need response from that function whether the email is sent or canceled by the user 我有一个电子邮件功能,可以为此发送多封电子邮件,我需要调用该功能,并且无论该电子邮件是由用户发送还是取消,我都需要该功能的响应
def send_mail_report(reporting_message, to_email, msg_subject):
olMailItem = 0x0
obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = msg_subject
newMail.Body = reporting_message
newMail.To = to_email
SEND_EMAIL = newMail.display()
time.sleep(16)
if SEND_EMAIL:
return "Sent"
else:
return "Failed"
i need to get response from this function 我需要从此功能获得响应
Here is sample code 这是示例代码
import smtplib
server = smtplib.SMTP(smtp_host,25)
server.sendmail('sender','email_recepient','msg')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.