Send Mail via Exchange Online
Script
function Send-Mail {
param (
[String]$Recipient,
[String]$CCRecipient
)
$MailBody = @"
{
"message": {
"subject": "App Secret laeuft bald ab!",
"body": {
"contentType": "Text",
"content": "Folgendes App Secret laeuft bald ab:
App Name: $($App.displayName)
App ID: $($Ob.AppID)
Secret ID: $($Ob.SecretID)
Ablaufdatum: $($OB.ExpiryDate) (in $($OB.ExpiresInXDays) Tagen)
Bitte melde dich beim ServiceDesk, um ein neues Secret zu generieren."
},
"toRecipients": [
{
"emailAddress": {
"address": "$Recipient"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"address": "$CCRecipient"
}
}
]
},
"saveToSentItems": "true"
}
"@
Write-Host "Sending Mail to $Recipient and $CCRecipient (CC)."
#Invoke-RestMethod -Method Post -Uri "https://graph.microsoft.com/v1.0/users/538b1f80-52c1-48b8-9849-afd6b46bf233/sendMail" -Headers $Header -ContentType "application/json" -Body $MailBody
}
Send-Mail -Recipient "<primarymailadress>" -CCRecipient "<ccmailadress>"