import requests
import msal
# Microsoft Azure AD Credentials
CLIENT_ID = "*************"
CLIENT_SECRET = "**************"
TENANT_ID = "****************"
GRAPH_API_URL = ".0"
# Get Access Token using MSAL
app = msal.ConfidentialClientApplication(CLIENT_ID, authority=f"/{TENANT_ID}", client_credential=CLIENT_SECRET)
token_response = app.acquire_token_for_client(scopes=["/.default"])
if "access_token" not in token_response:
print("❌ Failed to get access token:", token_response)
exit()
access_token = token_response["access_token"]
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
# Define Meeting Data
meeting_data = {
"subject": "Team Meeting",
"body": {
"contentType": "HTML",
"content": "This is a scheduled Microsoft Teams meeting."
},
"start": {
"dateTime": "2025-02-05T12:00:00",
"timeZone": "UTC"
},
"end": {
"dateTime": "2025-02-05T13:00:00",
"timeZone": "UTC"
},
"location": {
"displayName": "Microsoft Teams"
},
"attendees": [
{
"emailAddress": {
"address": "[email protected]",
"name": "Kannan M"
},
"type": "required"
}
],
"isOnlineMeeting": True,
"onlineMeetingProvider": "teamsForBusiness"
}
USER_ID = "[email protected]"
# Create the Meeting Event
response = requests.post(f"{GRAPH_API_URL}/users/{USER_ID}/events", headers=headers, json=meeting_data)
# Print Response
if response.status_code == 201:
print("✅ Meeting created successfully!")
print(response.json())
else:
print("❌ Failed to create meeting:", response.json())
The event was created successfully, but the attendees did not receive the email. When we checked, it showed: 'Delivery has failed to these recipients or groups: [email protected] Your message wasn’t delivered because the recipient’s email provider rejected it. Remote server returned '550 5.7.708 Service unavailable. Access denied, traffic not accepted from this IP. For more information please go to /?LinkId=526653 AS(7230)
i already enabled the permissions calendars.ReadWrite, OnlineMeetings.ReadWrite but did not send the email
I try that code event is created but mail not get attendees
import requests
import msal
# Microsoft Azure AD Credentials
CLIENT_ID = "*************"
CLIENT_SECRET = "**************"
TENANT_ID = "****************"
GRAPH_API_URL = "https://graph.microsoft.com/v1.0"
# Get Access Token using MSAL
app = msal.ConfidentialClientApplication(CLIENT_ID, authority=f"https://login.microsoftonline.com/{TENANT_ID}", client_credential=CLIENT_SECRET)
token_response = app.acquire_token_for_client(scopes=["https://graph.microsoft.com/.default"])
if "access_token" not in token_response:
print("❌ Failed to get access token:", token_response)
exit()
access_token = token_response["access_token"]
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
# Define Meeting Data
meeting_data = {
"subject": "Team Meeting",
"body": {
"contentType": "HTML",
"content": "This is a scheduled Microsoft Teams meeting."
},
"start": {
"dateTime": "2025-02-05T12:00:00",
"timeZone": "UTC"
},
"end": {
"dateTime": "2025-02-05T13:00:00",
"timeZone": "UTC"
},
"location": {
"displayName": "Microsoft Teams"
},
"attendees": [
{
"emailAddress": {
"address": "[email protected]",
"name": "Kannan M"
},
"type": "required"
}
],
"isOnlineMeeting": True,
"onlineMeetingProvider": "teamsForBusiness"
}
USER_ID = "[email protected]"
# Create the Meeting Event
response = requests.post(f"{GRAPH_API_URL}/users/{USER_ID}/events", headers=headers, json=meeting_data)
# Print Response
if response.status_code == 201:
print("✅ Meeting created successfully!")
print(response.json())
else:
print("❌ Failed to create meeting:", response.json())
The event was created successfully, but the attendees did not receive the email. When we checked, it showed: 'Delivery has failed to these recipients or groups: [email protected] Your message wasn’t delivered because the recipient’s email provider rejected it. Remote server returned '550 5.7.708 Service unavailable. Access denied, traffic not accepted from this IP. For more information please go to http://go.microsoft.com/fwlink/?LinkId=526653 AS(7230)
i already enabled the permissions calendars.ReadWrite, OnlineMeetings.ReadWrite but did not send the email
I try that code event is created but mail not get attendees
Share Improve this question edited Feb 6 at 23:33 Phil 165k25 gold badges261 silver badges267 bronze badges asked Feb 5 at 10:28 Thamara KannanThamara Kannan 11 bronze badge 2- Since you are using Microsoft Graph API, ensure that your Azure tenant allows SMTP mail flow for automated messages. – Rajesh Commented Feb 5 at 10:36
- I have already enabled the necessary permissions for SMTP mail flow in my Azure tenant for automated messages. – Thamara Kannan Commented Feb 6 at 13:06
1 Answer
Reset to default 0 'Delivery has failed to these recipients or groups: [email protected] Your message wasn’t delivered because the recipient’s email provider rejected it. Remote server returned '550 5.7.708 Service unavailable. Access denied, traffic not accepted from this IP. For more information please go to http://go.microsoft.com/fwlink/?LinkId=526653 AS(7230)
The issue is nothing to do with the code or Graph its because the destination mail endpoint your trying to send to is rejecting email from the source (your m365 tenant SMTP Mta). If you using a Developer or Trial Tenant this is to be expected because these environments are often exploited by various actors so end up on block lists. If its a production system get you admin to check email flow between the two SMTP endpoints (eg Mailflow https://learn.microsoft.com/en-us/exchange/mail-flow-best-practices/mail-flow-best-practices) in the m365 portal.