Home > Enterprise >  How to open Outlook template with using Python
How to open Outlook template with using Python

Time:07-21

I would like to know if there is a way to open a template outloook which is stored on my Network Attached Storage (NAS). I'm trying to open test.msg

import win32com.client

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
    
msg = outlook.OpenSharedItem(r"C:\Users\Cyche\test.msg")

I tried msg.open() it doesnt work :/

CodePudding user response:

I am still not sure what you are asking, but the following should do the job.

import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem(r"C:\Users\Cyche\test.msg")
msg.Subject = "Modified Subject"
msg.Save()

CodePudding user response:

Thanks Dmitry, you helped me.

I just add this line to open the template :

msg.Display()

Ty a lot

  • Related