title: Using an array for the Body in Send-MailMessage
body: <p>I have a small script that looks through AD and finds user's EmployeeID numbers. But  When attempting to send mail then I am getting an error message like below.</p>
  
  <p>error message : </p>
  
  <pre><code>Send-MailMessage : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Body'. Specified method is not supported.
  At line:53 char:93
  + ... maddress -Body ($expiredaccounts) -BodyAsHtml
  +                    ~~~~~~~~~~~~~~~~~~
  + CategoryInfo          : InvalidArgument: (:) [Send-MailMessage], ParameterBindingException
  + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.SendMailMessage
  </code></pre>
  
  <p>here is my code : </p>
  
  <pre><code>$expiredaccounts = Search-ADAccount -AccountExpiring -TimeSpan 30.00:00:00 | Where-Object { $_.Enabled -eq $true } 
  $expiredaccounts | Select-Object name, SamAccountName, AccountExpirationDate, @{Name='EmployeeID';Expression={($_ |Get-ADUser -Properties employeeID).employeeID}}, @{Name='EmployeeID2';Expression={($_ |Get-ADUser -Properties pager).pager}} |  ConvertTo-Html | Out-String
  
  Send-MailMessage -to $emailto -Subject $subject -SmtpServer $smtp -From $fromaddress -Body ($expiredaccounts) -BodyAsHtml
  </code></pre>