I am trying to send mail from another account (which is configured in my outlook but not default account) using the below code. The problem is when i keep mail.display(True) it is showing the account name but when i keep the mail.send instead of mail.display(True) the mail going from the default account.
from win32com.client import Dispatch
import win32com
outlook = win32com.client.Dispatch("Outlook.Application")
mail = outlook.CreateItem(0)
mail.SentOnBehalfOfName = 'xyz@gmail.com'
mail.To = 'mymail@gmail.com'
mail.Subject = 'Hello'
mail.HTMLBody = template
mail.send