Hello everyone,
I am wondering if anyone knows how to construct a body parameter for Send-MgUserMail cmdlet so it takes a variable with stored data, and send them in a body of an email (my goal is to send this from Azure automation runbook).
Contents of the variable look like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML TABLE</title>
</head><body>
<table>
<colgroup><col/><col/></colgroup>
<tr><th>DisplayName</th><th>UserPrincipalName</th></tr>
<tr><td>Surname Name 1</td><td>******@etc.com</td></tr>
<tr><td>Surname Name 2</td><td>******@etc.com</td></tr>
<tr><td>Surname Name 3</td><td>******@etc.com</td></tr>
<tr><td>Surname Name 4</td><td>******@etc.com</td></tr>
<tr><td>Surname Name 5</td><td>******@etc.com</td></tr>
<tr><td>Surname Name 6</td><td>******@etc.com</td></tr>
</table>
</body></html>
And when I want to define email parameters according to following scheme...
Import-Module Microsoft.Graph.Users.Actions
$params = @{
Message = @{
Subject = "Meet for lunch?"
Body = @{
ContentType = "Text"
Content = "The new cafeteria is open."
}
ToRecipients = @(
@{
EmailAddress = @{
Address = "******@contoso.onmicrosoft.com"
}
}
)
CcRecipients = @(
@{
EmailAddress = @{
Address = "******@contoso.onmicrosoft.com"
}
}
)
}
SaveToSentItems = "false"
}
# A UPN can also be used as -UserId.
Send-MgUserMail -UserId $userId -BodyParameter $params
...I am not sure how to fit the variable into this - is it possible to just reference a variable or do I need to construct it in a different way?
Is it possible to somehow define ContentType as variable and then just put it there?
Many thanks for your help,
Tomas