1 回答
TA贡献1830条经验 获得超3个赞
如果您真的需要打开 Outlook,也许这将是 Open Outlook with Python的副本
os.startfile("outlook")
对于 macOS:
subprocess.call(["open", filename])
另一方面,如果只是发送电子邮件有帮助,请检查 smtplib。
要开始一条空白消息,请使用以下命令:
import webbrowser
webbrowser.open('mailto:', new=1)
要编写您的电子邮件,您可以使用 smtplib(如上所述)+ 检查: https ://realpython.com/python-send-email/#sending-a-plain-text-email
步骤1 :
import smtplib, ssl
port = 465 # For SSL
password = input("Type your password and press enter: ")
# Create a secure SSL context
context = ssl.create_default_context()
with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server:
server.login("my@gmail.com", password)
# TODO: Send email here
第2步 :
server.sendmail(sender_email, receiver_email, message)
sender_email = "my@gmail.com"
receiver_email = "your@gmail.com"
message = """\
Subject: Hi there
This message is sent from Python."""
# Send email here
添加回答
举报
