如何使用Python生成和打开Outlook电子邮件(但不要发送) [英] How do I generate and open an Outlook email with Python (but do not send)

查看:3482
本文介绍了如何使用Python生成和打开Outlook电子邮件(但不要发送)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  def Emailer(text,主题,收件人):
导入win32com.client作为win32

outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To =收件人
mail.Subject =主题
mail.HtmlBody =文本
mail.send

但是如何在Outlook窗口中打开此电子邮件,以便可以手动编辑和发送?



理想情况下, d喜欢这样的东西:

  def __Emailer(text,subject,recipient,auto = True):
import win32com .client as win32

outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To =收件人
邮件.Subject = subject
mail.HtmlBody = text
如果auto:
mail.send
else:
mail.open#或任何正确的代码是

提前感谢

解决方案

调用 mail.Display(True)而不是 mail.send


I have a script that automatically creates and sends emails sends emails using the simple function below:

def Emailer(text, subject, recipient):
    import win32com.client as win32   

    outlook = win32.Dispatch('outlook.application')
    mail = outlook.CreateItem(0)
    mail.To = recipient
    mail.Subject = subject
    mail.HtmlBody = text
    mail.send

But how do I open this email in an Outlook window so that it can be manually edited and sent?

Ideally, I'd like something like this:

def __Emailer(text, subject, recipient, auto=True):
    import win32com.client as win32   

    outlook = win32.Dispatch('outlook.application')
    mail = outlook.CreateItem(0)
    mail.To = recipient
    mail.Subject = subject
    mail.HtmlBody = text
    if auto:
        mail.send
    else:
        mail.open # or whatever the correct code is

Thanks in advance

解决方案

Call mail.Display(True) instead of mail.send

这篇关于如何使用Python生成和打开Outlook电子邮件(但不要发送)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆