Releases: pixelbyaj/msgraph-email
Releases · pixelbyaj/msgraph-email
Python package released for read/send email using msgraph apis
msgraph-email v1.1.0
Microsoft Graph Email API using Python
Installation
msgraph-email is available on PyPI.
pip install msgraph-email
Import modules
from mail.msgraph import EmailService
from mail.models import EmailMessage,EmailAttachment
Configure a Email_Service
emailService = EmailService(tenant_id, client_id, client_secret, email_address)
Make a read email request
By default it will read unread emails of the 'Inbox' mailfolder
emailMessages= emailService.readEmails()
Make a send email request
emailMessage = EmailMessage()
emailMessage.toEmails="[email protected]"
emailMessage.message="Hello"
emailService.sendEmail(message)
Make a read and unread email request
emailMessages = emailService.readEmails()
for email in emailMessages:
#mark it read
emailService.markEmailReadUnRead(email.messageId,isRead=True)
#mark it unread
#emailService.markEmailReadUnRead(email.messageId,isRead=False)
Make a delete email request
emailMessages = emailService.readEmails()
for email in emailMessages:
emailService.deleteEmail(email.messageId)