Created
May 15, 2023 17:07
-
-
Save indybeck/91c3b45bfc9444802e80a7fa69e98220 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from O365 import Account | |
from O365 import Message | |
client_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" | |
client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | |
tenant_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" | |
t_client_id = client_id + '@' + tenant_id | |
def send_email(): | |
print('Starting send_email function') | |
credentials = (t_client_id, client_secret) | |
account = Account(credentials, auth_flow_type='credentials', tenant_id=tenant_id) | |
if account.authenticate(): | |
print('Authenticated!') | |
m = account.new_message(resource='notification@yourdomain.com') | |
m.to.add(['someone@somedomain.com']) | |
m.subject = 'Test email: Best quote' | |
m.body = 'Just one small positive thought in the morning can change your whole day.' | |
#m.attachments.add('best_quotes.txt') | |
m.send() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment