hey everyone! i'm pretty new to using API's and am getting a bit frustrated with why the sendMail code doesn't work correctly when i install the microsoft sdk package.
Problem is i don't seem to be able to use the SendMailPostRequestBody method. This is what i currently have imported in my python file:
import logging
import requests
import msal
import asyncio
from azure.identity.aio import ClientSecretCredential
from msgraph import GraphServiceClient
import msgraph_core
import msgraph
I'm trying to use the example code seen on the user:sendMail of the Microsoft Graph documentation. Please see below:
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(credentials, scopes)
request_body = SendMailPostRequestBody(
message = Message(
subject = "Meet for lunch?",
body = ItemBody(
content_type = BodyType.Text,
content = "The new cafeteria is open.",
),
to_recipients = [
Recipient(
email_address = EmailAddress(
address = "******@contoso.onmicrosoft.com",
),
),
],
cc_recipients = [
Recipient(
email_address = EmailAddress(
address = "******@contoso.onmicrosoft.com",
),
),
],
),
save_to_sent_items = False,
)
await graph_client.me.send_mail.post(request_body)
Any helps is greatly appreciated!