简体   繁体   中英

Create and send an e-mail with a scheduled time in outlook with python

I would like to create and send an e-mail with a scheduled time (with delay delivery in the options tab) in outlook with python. The script below simply sends an email without a delivery time option:

import win32com.client as win32 
def Emailer(text, subject, recipient):
 outlook = win32.Dispatch('outlook.application')
 mail = outlook.CreateItem(0)
 mail.To = recipient
 mail.Subject = subject
 mail.HtmlBody = text
 mail.send

I added the line below, as an example, it worked.

mail.DeferredDeliveryTime = datetime.datetime(2022, 4, 1, 17, 29, 25, tzinfo=datetime.timezone.utc)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM