使用 Python 将多项选择参数解析为 Outlook 表单

问题描述 投票:0回答:1

在我的公司,当我使用 Outlook 发送电子邮件时,点击“发送”后,会触发“操作事件”,这是一个标题为“选择表单”的弹出窗口,要求从下拉列表中进行选择。我选择,然后单击“确定”,电子邮件就会发送。

运行以下代码后,会弹出“选择表单”。我想找到一种从代码内填充表单的方法,以便在无需手动干预的情况下发送电子邮件

import win32com.client as win32
 
olApp = win32.Dispatch('Outlook.Application')
olNS = olApp.GetNameSpace('MAPI')
 
# construct email item object
mailItem = olApp.CreateItem(0)
mailItem.Subject = 'Hello 123'
mailItem.BodyFormat = 1
mailItem.Body = 'Hello There'
mailItem.To = '<recipient email>'
mailItem.Sensitivity  = 2
# optional (account you want to use to send the email)
mailItem._oleobj_.Invoke(*(64209, 0, 8, 0, olNS.Accounts.Item('<senders email>')))
mailItem.Display()
#mailItem.Save()
mailItem.Send()
python outlook pywin32 win32com office-automation
1个回答
0
投票

听起来 Outlook 加载项或 VBA 宏正在 Outlook 中运行(用于显示此类对话框),因为您在代码中正确设置了 MailItem.SendUsingAccount 属性。您可以向开发人员询问可供开发人员使用并且可以从脚本中调用的任何公共接口。例如,请参阅演练:从 VBA 调用 VSTO 外接程序中的代码了解更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.