I am on a business project with python, where my team will send out an automated report in some teams. The code for sending it out works quite well:
import win32com.client as win32
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = 'To address'
mail.Subject = 'Message subject'
mail.Body = 'Message body'
mail.HTMLBody = '<h2>HTML Message body</h2>' #this field is optional
# To attach a file to the email (optional):
attachment = "Path to the attachment"
mail.Attachments.Add(attachment)
mail.Send()
Thanks to this thread: Send Outlook Email Via Python?
Is there anyway to change the adress of the sender, something like:
mail.From = 'Team Adress'
Otherwise the problem will be that people will answer the mail to my e-mail adress, which will be so wrong approach. Or is that not possible at all, because It has to open my outlook account?