[英]Create a file that will automatically send an e-mail when clicked on?
我的程序獲取輸入的數據並創建幾個批處理/docx 文件。 有沒有辦法獲取我輸入的數據並創建一個文件,單擊該文件后,該文件會自動從特定 Gmail 帳戶向指定的電子郵件地址發送電子郵件? 或者更好的是,打開 chrome 並准備要發送的電子郵件和所有內容?
我想使用的 Gmail 帳戶是委托的(由各種用戶控制),並且電子郵件必須來自該帳戶,而不是我登錄的個人 Gmail 帳戶。
編輯:它不必打開 chrome。 可以是任何東西。 只要我可以在點擊發送之前進行更改。
創建一個批處理文件,該文件將運行您創建的 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 代碼。 它應該提示您輸入 - 要發送的電子郵件消息 - 然后它會發送電子郵件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.