Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choosing "From" field using python win32com outlook

I am trying to automate emails using python. Unfortunately, the network administrators at my work have blocked SMTP relay, so I cannot use that approach to send the emails (they are addressed externally).

I am therefore using win32com to automatically send these emails via outlook. This is working fine except for one thing. I want to choose the "FROM" field within my python code, but I simply cannot figure out how to do this.

Any insight would be greatly appreciated.

like image 446
user2689931 Avatar asked Dec 30 '25 16:12

user2689931


1 Answers

If you configured a separate POP3/SMTP account, set the MailItem.SendUsingAccount property to an account from the Namespace.Accounts collection.

If you are sending on behalf of an Exchange user, set the MailItem.SentOnBehalfOfName property

like image 148
Dmitry Streblechenko Avatar answered Jan 01 '26 06:01

Dmitry Streblechenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!