我的程序获取输入的数据并创建几个批处理/ docx文件。有没有办法获取我输入的数据并创建一个文件,当单击该文件时,该文件会自动将电子邮件从特定的Gmail帐户发送到指定的电子邮件地址?还是更好,打开chrome并准备向电子邮件发送文本和所有内容?
我要使用的Gmail帐户是委派的(由多个用户控制),电子邮件必须来自此帐户,而不是我登录的个人Gmail帐户。
编辑:不必打开镶边。可以是任何东西。只要我可以在发送之前进行更改。
答案 0 :(得分:0)
创建一个批处理文件,该批处理文件将运行您创建的python文件 例如,带有以下行的批处理文件
python -m your_module.your_python_file
使用以下代码创建一个名为your_python_file.py的python文件
import logging
from logging.handlers import SMTPHandler
if(__name__ == "__main__"):
logger = logging.getLogger()
server_email_address = 'your_gmail_address'
server_account_password = 'your_gmail_password'
destination_email_address = 'destination_email_address'
emailh = SMTPHandler(('smtp.gmail.com', 587)
,server_email_address
,destination_email_address
,'your subject'
,(server_email_address, server_account_password)
, secure=())
emailh.setLevel(logging.WARNING)
logger.addHandler(emailh)
# input the email message to send
msg = input('enter message \n')
# send the email
logger.warning(msg)
当您单击批处理文件时,它将打开一个控制台窗口并运行python代码。它会提示您输入-要发送的电子邮件-然后它将发送电子邮件