ms-graph-email
Microsoft Graph API email access for Microsoft 365 accounts via direct API calls.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Microsoft Graph API email access for Microsoft 365 accounts via direct API calls.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Multi-layered security system protecting against prompt injection, secret extraction, and malicious content. Based on defense-in-depth principles.
Cognitive control memory system based on "On Task" by David Badre. Handles input gating, output gating, hierarchical memory, and procedural runbooks.
Manage Facebook Pages and Instagram Business via Meta Graph API. Post content (text, photos, videos, reels), list posts, manage comments. Use for social media publishing.
Generate and post thought leadership videos using HeyGen and distribute to multiple platforms.
Publish and manage blog posts on WordPress sites via REST API. Supports creating posts, drafts, uploading media, and managing categories/tags.
| name | ms-graph-email |
| description | Microsoft Graph API email access for Microsoft 365 accounts via direct API calls. |
| homepage | https://docs.microsoft.com/en-us/graph/ |
| metadata | {"openclaw":{"emoji":"📧","requires":{"bins":["python3","security"]},"install":[{"id":"native","kind":"native","bins":["python3"],"label":"Python 3 required for MS Graph API scripts"}]}} |
Access Microsoft 365 email via Microsoft Graph API.
Credentials are stored in macOS Keychain:
openclaw-microsoft365Store credentials as JSON:
{
"tenant_id": "your-tenant-id",
"client_id": "your-client-id",
"client_secret": "your-client-secret"
}
security add-generic-password -s "openclaw-microsoft365" -a "graph" \
-w '{"tenant_id":"xxx","client_id":"xxx","client_secret":"xxx"}' -U
import json, subprocess, requests
result = subprocess.run(
['security', 'find-generic-password', '-s', 'openclaw-microsoft365', '-w'],
capture_output=True, text=True
)
creds = json.loads(result.stdout.strip())
token_response = requests.post(
f"https://login.microsoftonline.com/{creds['tenant_id']}/oauth2/v2.0/token",
data={
'grant_type': 'client_credentials',
'client_id': creds['client_id'],
'client_secret': creds['client_secret'],
'scope': 'https://graph.microsoft.com/.default'
}
)
token = token_response.json()['access_token']
Set your mailbox in scripts or as environment variable:
MAILBOX = "user@yourdomain.com"
response = requests.get(
f'https://graph.microsoft.com/v1.0/users/{MAILBOX}/messages',
headers={'Authorization': f'Bearer {token}'},
params={
'$top': 10,
'$orderby': 'receivedDateTime desc',
'$select': 'id,subject,from,receivedDateTime,bodyPreview,isRead'
}
)
emails = response.json().get('value', [])
params={
'$filter': 'isRead eq false',
'$orderby': 'receivedDateTime desc',
'$top': 20
}
# Search by sender, subject, or body content
params={
'$search': '"from:sender@example.com" OR "keyword"',
'$top': 20
}
# Search with date filter
from datetime import datetime, timedelta
last_week = (datetime.utcnow() - timedelta(days=7)).strftime('%Y-%m-%dT%H:%M:%SZ')
params={
'$filter': f'receivedDateTime ge {last_week}',
'$search': '"important" OR "urgent"'
}
response = requests.get(
f'https://graph.microsoft.com/v1.0/users/{MAILBOX}/messages/{message_id}',
headers={'Authorization': f'Bearer {token}'},
params={'$select': 'subject,from,body,toRecipients,ccRecipients'}
)
email = response.json()
body_content = email['body']['content']
requests.post(
f'https://graph.microsoft.com/v1.0/users/{MAILBOX}/sendMail',
headers={'Authorization': f'Bearer {token}', 'Content-Type': 'application/json'},
json={
'message': {
'subject': 'Subject Line',
'body': {'contentType': 'Text', 'content': 'Email body'},
'toRecipients': [{'emailAddress': {'address': 'recipient@example.com'}}]
}
}
)
requests.post(
f'https://graph.microsoft.com/v1.0/users/{MAILBOX}/messages/{message_id}/reply',
headers={'Authorization': f'Bearer {token}', 'Content-Type': 'application/json'},
json={
'message': {
'body': {'contentType': 'Text', 'content': 'Reply content'}
}
}
)
response = requests.post(
f'https://graph.microsoft.com/v1.0/users/{MAILBOX}/messages',
headers={'Authorization': f'Bearer {token}', 'Content-Type': 'application/json'},
json={
'subject': 'Draft Subject',
'body': {'contentType': 'Text', 'content': 'Draft body'},
'toRecipients': [{'emailAddress': {'address': 'recipient@example.com'}}],
'isDraft': True
}
)
draft_id = response.json()['id']
requests.patch(
f'https://graph.microsoft.com/v1.0/users/{MAILBOX}/messages/{message_id}',
headers={'Authorization': f'Bearer {token}', 'Content-Type': 'application/json'},
json={'isRead': True}
)
requests.delete(
f'https://graph.microsoft.com/v1.0/users/{MAILBOX}/messages/{message_id}',
headers={'Authorization': f'Bearer {token}'}
)
# Full working example - search and read
import json, subprocess, requests
MAILBOX = "user@yourdomain.com"
# Auth
result = subprocess.run(['security', 'find-generic-password', '-s', 'openclaw-microsoft365', '-w'], capture_output=True, text=True)
creds = json.loads(result.stdout.strip())
token = requests.post(
f"https://login.microsoftonline.com/{creds['tenant_id']}/oauth2/v2.0/token",
data={'grant_type': 'client_credentials', 'client_id': creds['client_id'],
'client_secret': creds['client_secret'], 'scope': 'https://graph.microsoft.com/.default'}
).json()['access_token']
headers = {'Authorization': f'Bearer {token}'}
# Search for emails
response = requests.get(
f'https://graph.microsoft.com/v1.0/users/{MAILBOX}/messages',
headers=headers,
params={'$search': '"project update"', '$top': 10,
'$select': 'subject,from,receivedDateTime,bodyPreview'}
)
for email in response.json().get('value', []):
sender = email['from']['emailAddress']
print(f"{email['receivedDateTime']}: {sender['name']} - {email['subject']}")
Mail.Read, Mail.Send, Mail.ReadWrite (delegated or application)