python-o365
python-o365 copied to clipboard
Message sender.name is not honored in API call
Hello,
I have been trying to change the display name of the from
field when sending emails.
This parameter does not seem to be honored when requesting the emails end action
My code:
Sending email with default account name
>>> ne = mbox.new_message()
>>> ne.to.add('[email protected]')
>>> ne.subject = 'test subject'
>>> ne.body = 'body'
>>> ne.send()
Sending email with custom from
- notice there is no "from" key in the api payload
>>> ne = mbox.new_message()
>>> ne.to.add('[email protected]')
>>> ne.subject = 'test subject'
>>> ne.body = 'body'
>>> ne.sender.name = "custom name"
>>> ne.to_api_data()
{'subject': 'test subject', 'body': {'contentType': 'HTML', 'content': 'body'}, 'importance': 'normal', 'flag': {'flagStatus': 'notFlagged'}, 'isReadReceiptRequested': False, 'isDeliveryReceiptRequested': False, 'toRecipients': [{'emailAddress': {'address': '[email protected]'}}]}
Sending email with custom from
and email address - not the additional "from" key in api payload
>>> ne = mbox.new_message()
>>> ne.to.add('[email protected]')
>>> ne.subject = 'test subject'
>>> ne.body = 'body'
>>> ne.sender.name = "custom name"
>>> ne.sender.address = '[email protected]'
>>> ne.to_api_data()
{'subject': 'test subject', 'body': {'contentType': 'HTML', 'content': 'body'}, 'importance': 'normal', 'flag': {'flagStatus': 'notFlagged'}, 'isReadReceiptRequested': False, 'isDeliveryReceiptRequested': False, 'toRecipients': [{'emailAddress': {'address': '[email protected]'}}], 'from': {'emailAddress': {'address': '[email protected]', 'name': 'custom name'}}}
All the code snippets above are valid and return True
but when the email arrives in my inbox, the custom from
values are disregarded and the default account name is displayed. Same as if I had not set the sender
attributes at all.
I'm not sure if this is the expected behavior of the sender
attribute or if this is indeed a bug. If anyone has dealt with something similar or if this is even possible.
The goal is to send an email from account Service account <[email protected]>
but display the name as Different name <[email protected]>
on arrival.
Thank you, Javier
when using sender we use the 'from' attribute from ms graph, which only accepts an address if not mistaken.
So no, we do not use the sender name currently.
Any update on this one?