Monday, June 22, 2026

test

 $body = @{

    client_id = "0b80c03e-de45-43c7-be0a-1e1adc86d792"
    client_secret = "fmt8Q~4nG1JrM50nipPp0YMdBpr.RXnAWagYsbRJ"
    scope = "https://graph.microsoft.com/.default"
    grant_type = "client_credentials"
}
$tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/bb55f134-02f1-478e-bc6a-82bf54373c6d/oauth2/v2.0/token" -Method POST -Body $body
$token = $tokenResponse.access_token

$mailBody = @{
    message = @{
        subject = "Test Email from GraphAPI_Flow"
        body = @{
            contentType = "Text"
            content = "This is a test email sent via Microsoft Graph API from Power Automate Desktop."
        }
        toRecipients = @(
            @{ emailAddress = @{ address = "sreekanth@vkn2k.onmicrosoft.com" } }
        )
    }
} | ConvertTo-Json -Depth 10

$headers = @{
    Authorization = "Bearer $token"
    "Content-Type" = "application/json"
}

$sendResult = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/users/sreekanth@vkn2k.onmicrosoft.com/sendMail" -Method POST -Headers $headers -Body $mailBody -ContentType "application/json"
Write-Output "Email sent successfully"

No comments:

Post a Comment

Featured Post

Send Emails via Microsoft Graph API Using PowerShell and App Registration

Send Emails via Microsoft Graph API Using PowerShell and App Registration Microsoft Graph API is the unified gateway to Microsoft 365 data ...

Popular posts