[英]Error when sending email in python through Outlook
I use the following approach for sending an email in Outlook.我使用以下方法在 Outlook 中发送 email。
import pandas as pd
import numpy as np
import win32com.client as win32
df = pd.DataFrame(np.array([[1, 2], [4, 5]]), index=('27-04-2020','28-04-2020'), columns=('Prediction', 'Certainty'))
html= df.to_html()
#SEND MAIL
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = 'my@mail.com'
mail.HTMLBody = html
mail.Subject = "Test"
mail.send
However, I get an error when running the code: pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', 'The operation failed.', None, 0, -2147467259), None)但是,运行代码时出现错误:pywintypes.com_error: (-2147352567, '发生异常。', (4096, 'Microsoft Outlook', '操作失败。', None, 0, -2147467259), None)
Do any of you have an idea for a solution?你们中有人有解决方案的想法吗?
It seems you are getting a standard security issue in Outlook...看来您在 Outlook 中遇到了标准安全问题...
There are several ways for suppressing such issues brought to us by the Outlook object model:有几种方法可以抑制 Outlook object model 给我们带来的此类问题:
Use a third-party components for supressing Outlook security warnings.使用第三方组件来抑制 Outlook 安全警告。 See Security Manager for Microsoft Outlook for more information.
有关详细信息,请参阅Microsoft Outlook 的安全管理器。
Use a low-level API instead of OOM.使用低级 API 代替 OOM。 Or any other third-party wrappers around that API, for example, Redemption.
或围绕该 API 的任何其他第三方包装器,例如 Redemption。
Develop a COM add-in that has access to the trusted Application
object.开发可以访问受信任
Application
object 的 COM 加载项。 And then communicate from a standalone application with an add-in using standard.Net tools (Remoting).然后使用标准.Net 工具(远程处理)从独立应用程序与加载项进行通信。
Use group policy objects for setting up machines.使用组策略对象来设置机器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.