python - 在Python中自动化时如何使用selenium处理Microsoft Outlook应用程序弹出窗口

标签 python python-3.x selenium-webdriver outlook

我正忙于在 python 中使用 selenium 包来自动化流程。我的流程要求我使用 Outlook 应用程序发送电子邮件,但是当我尝试使用以下代码从 python 发送电子邮件时:

outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = 'email_address'

mail.Subject = 'Email Subject'
mail.Body = 'Email Body'
attachment = 'Attachment'
mail.Attachments.Add(attachment)

我从 Outlook 中收到此弹出窗口: enter image description here

Selenium 仅适用于基于网络的自动化,我如何使用 python 解决这个问题,以便每当我发送电子邮件时它都会自动单击“允许”,而无需手动执行。

我查看了 Outlook 2016 编程访问设置,防病毒状态无效: enter image description here

最佳答案

当您访问任何安全属性或仅发送项目时,您会收到 Outlook 生成的标准安全提示。您可以在"A program is trying to send an e-mail message on your behalf" warning in Outlook中阅读更多相关信息。文章。

有多种方法可以避免发送电子邮件时出现此类提示:

  1. 使用 Outlook 安全管理器,它允许在运行时关闭和打开安全提示。请参阅Security Manager获取示例代码。
  2. 使用不会触发安全提示的低级 API - 扩展 MAPI 或该 API 的任何其他包装器,例如 Redemption
  3. 开发一个可以访问可信应用程序对象的COM加载项。
  4. 使用组策略对象将计算机设置为不触发安全提示。

关于python - 在Python中自动化时如何使用selenium处理Microsoft Outlook应用程序弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59658692/

相关文章:

c# - 使用 Selenium Webdriver 测试元素是否聚焦

python - SciPy 中使用截断法线的混合模型拟合(双峰?)。 python 3

python - 在图像中发现不完全相同的模板

python - 检查所有属性是否作为字典键存在于嵌套元组的一个(且仅有一个)索引中

python - Selenium/Webdriver 的 python 绑定(bind)中的 get_Text() 等价物是什么

javascript - 如何在 executeScript 方法中显示带有变量的 javascript 代码?

python - 负 'Start training from score'

python - 从另一个文件导入类

python-3.x - 为什么 python 字符串连接最省内存?

Python 名称错误 : name is not defined (related to having default input argument types)