打开电子邮件窗口以允许物理输入

时间:2018-11-15 20:55:44

标签: python outlook

我希望用户能够在Outlook的实际实例中手动完成电子邮件,而不是在外壳中对值或输入进行硬编码。

import win32com.client as win32
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = '***'
mail.Subject = '***'
mail.Body = '***'
mail.Send()

2 个答案:

答案 0 :(得分:0)

内置的input()。示例:

import win32com.client as win32
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = input("Mail to: ")
mail.Subject = input("Mail Subject: ")
mail.Body = input("Mail Body: ")
attachment = str(output_file)
attachpath = "my_attachment_path"
attachfull = attachpath+attachment
attachf = str(attachfull)
mail.Attachments.Add(Source=attachf)
mail.Send()

答案 1 :(得分:0)

请勿呼叫mail.Send()-呼叫mail.Display(true)以模态显示消息。