2

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

THAVASI.T
  • 131
  • 1
  • 5

1 Answers1

0

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)