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

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

问题描述

我有一个脚本可以自动创建和发送电子邮件 使用下面的简单函数发送电子邮件:

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

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

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

推荐答案

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

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

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