如何使用 Microsoft Graph API 转发电子邮件?
API 中提供了转发选项。我在 Microsoft Graph Explorer 上对其进行了在线测试:https://developer.microsoft.com/en-us/graph/graph-explorer
这是我的实际脚本
from O365 import Account, message
credentials = ('client id', 'secret client')
account = Account(credentials)
print(account)
if account.authenticate(scopes=['basic', 'message_all']):
print('Authenticated!')
# Send Email
m = account.new_message()
m.to.add('test@gmail.com')
m.subject = 'Fun!'
m.body = "George Best quote: I've stopped drinking, but only while I'm asleep."
m.send()
# Read Inbox Emails
print("Inbox Emails:")
mailbox = account.mailbox()
inbox = mailbox.inbox_folder()
for message in inbox.get_messages(1):
print(message)
# Read Sent Emails
print("Sent Emails:")
mailbox = account.mailbox()
sent_folder = mailbox.sent_folder()
for message in sent_folder.get_messages(1):
print(message)
# Forward Email