Reputation: 3041
I am looking to send a saved email template to a user using Python.
This is my current Python function using Win32 library.
How can I adjust this to pick up the template and then send it?
def send_email(sender,recipient):
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = recipient
mail.Subject = Subject_Req
mail.HTMLBody = Content_Email
mail.SentOnBehalfOfName = sender
mail.GetInspector
mail.Send()
I am not able to find the corresponding property.
Upvotes: 0
Views: 4785
Reputation: 644
Use CreateItemFromTemplate.
https://learn.microsoft.com/en-us/office/vba/api/outlook.application.createitemfromtemplate
def send_email(sender,recipient):
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItemFromTemplate("pathToTemplate", )
mail.To = recipient
mail.Subject = Subject_Req
mail.HTMLBody = Content_Email
mail.SentOnBehalfOfName = sender
mail.GetInspector
mail.Send()
Upvotes: 1