如何python win32com使用EML文件O​​pen Outlook。附件文件提取和身体内容阅读

发布于 2025-01-23 05:58:06 字数 899 浏览 3 评论 0原文

Python win32com使用Open Outlook.ApplicationEML 附件文件提取。并阅读主题和身体内容。使用Python本机包使用。 EML文件格式。

代码

import win32com.client

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem("C:\\sample\\todo.eml")

print(msg)

错误

Traceback (most recent call last):
  File "init.py", line 4, in <module>
    msg = outlook.OpenSharedItem("C:\\sample\\todo.eml")
  File "<COMObject GetNamespace>", line 2, in OpenSharedItem
pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, 
'Microsoft Outlook', 'Invalid path or URL.', None, 0, -2147352567), None)

python使用EML文件打开Win32COM模块用于使用。 分享的任何想法

python win32com use open Outlook.Application. eml attachment files extract. and read subject and body content. use python native package use. eml file format.

Code

import win32com.client

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem("C:\\sample\\todo.eml")

print(msg)

error

Traceback (most recent call last):
  File "init.py", line 4, in <module>
    msg = outlook.OpenSharedItem("C:\\sample\\todo.eml")
  File "<COMObject GetNamespace>", line 2, in OpenSharedItem
pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, 
'Microsoft Outlook', 'Invalid path or URL.', None, 0, -2147352567), None)

python use eml file open win32com module to use.
any ideas to share

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍风燃霜 2025-01-30 05:58:06

这可能是有两个原因:
1.-命令:“ Outlook.opensharedItem [...]” 也不能像以前一样在控制台中执行,即使您使用“ CMD”,相同的行也会给您相同的错误。
2.-您在PC上没有安装Outlok(这是执行此类命令所必需的)

It can be for two reasons:
1.- The command: " outlook.OpenSharedItem[...]" cannot be executed in the console as before, even if you use "cmd", this same line will give you the same error.
2.- You do not have Outlok installed on your PC (which is necessary to execute this type of command)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文