i can create with python outlook emails and send them. Im Using win32com.client. I want to ask how i can send emails from the same account but simulate different sender emails and timestamp(date and time) random?
I have tried it with https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.senderemailaddress
newMail.SenderEmailAddress = "[email protected]"
It didnt worked. I got: AttributeError: Property 'CreateItem.SenderEmailAddress' can not be set
CodePudding user response:
The SenderEmailAddress property is read-only and set on received or sent emails, not composed ones.
The Outlook object model provides two main ways for sending emails from other accounts:
- The MailItem.SendUsingAccount property which returns or sets an
Account
object that represents the account under which theMailItem
is to be sent. In that case the other account should be configured in an Outlook profile as well. - The MailItem.SentOnBehalfOfName property which returns or sets a string indicating the display name for the intended sender of the mail message. In that case you need to have all the required permissions to do that on behalf of another person. Valid for Exchange only.
CodePudding user response:
On a general note, no mail server (certainly not Exchange Server) will let you spoof the sender name and address (unless you were given an explicit permisison) for the obvious security reasons.
You can send on behalf of another Exchange user (if you have the permission) by setting the MailItem.SentOnBehalfOfName
property. You can also create secondary Exchange / POP3/SMTP / IMAP4/SMTP accounts in Outlook and send through these accounts by setting the MailItem.SendUsingAccount
property to an Account
object from the Application.Session.Accounts
collection.