'how to python win32com use eml file open outlook. attachment file extract and body content read

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



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source