Haxguy

send_email_exchangelib

Jun 27th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import exchangelib
  2. import getpass
  3.  
  4.  
  5. credentials = exchangelib.Credentials(username='domain.com\\username', password=getpass.getpass())
  6. config = exchangelib.Configuration(server='my.mailserver.com', credentials=credentials)
  7.  
  8.  
  9. m = exchangelib.Message(
  10.     account=exchangelib.Account(primary_smtp_address='myemail@email.com', credentials=credentials,
  11.                                 autodiscover=False, config=config, access_type=exchangelib.DELEGATE),
  12.     subject='Test',
  13.     body=exchangelib.HTMLBody('<html><body>Hello happy <blink>OWA user!</blink></body></html>'),
  14.     to_recipients=[exchangelib.Mailbox(email_address='destination@email.com')]
  15.  
  16. )
  17. m.send()
Add Comment
Please, Sign In to add comment