'O365 API, Forward an Email
Is there anyway to forward a message using o365 API ?
This is what i tried to far:
# Authentification
from O365 import Account, message
credentials = ('Client_ID', 'Secret_Client')
account = Account(credentials)
print(account)
if account.authenticate(scopes=['basic', 'message_all']):
print('Authenticated!')
# Read Sent Email :
mailbox = account.mailbox()
sent_folder = mailbox.sent_folder()
for message in sent_folder.get_messages(1):
print(message)
Is there any way how to forward that message ?
I saw that it's possible on microsoft graph using php : https://developer.microsoft.com/fr-fr/graph/graph-explorer : Check Mail : Forward Mail
Solution 1:[1]
You have to create a new forward() instance of the email and add data just like you would when creating a new message:
# Authentification
from O365 import Account, message
credentials = ('Client_ID', 'Secret_Client')
account = Account(credentials)
print(account)
if account.authenticate(scopes=['basic', 'message_all']):
print('Authenticated!')
# Read Sent Email :
mailbox = account.mailbox()
sent_folder = mailbox.sent_folder()
for message in sent_folder.get_messages(1):
# Forward email to '[email protected]' with 'Added body' above the forwarded email body:
to_forward = message.forward()
to_forward.to.add('[email protected]')
to_forward.body = 'Added body'
to_forward.send()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jutta |
