I have three mailboxes on my Outlook. How can I use my other mailbox in sending email via Python? The below script currently uses my main inbox = [email protected]. How can I use my other mailbox ([email protected]) in sending the email on the script?
import win32com.client as win32
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.GetInspector
mail.To = '[email protected]'
mail.CC = '[email protected]'
mail.Subject = 'Test Email'
index = mail.HTMLbody.find('>', mail.HTMLbody.find('<body'))
mail.HTMLbody = mail.HTMLbody[:index + 1] + 'Hello,<br> <br>This is a test email<br><br>Many thanks and kind regards. ' + mail.HTMLbody[index + 1:]
mail.Send()
If it is an Exchange mailbox, set the MailItem.SentOnBehalfOfName
property to the name of the delegate mailbox.