Hi,
Im trying to write a script to send the result of variable ($content) as the body :
$content = ls -Path $folder | Sort-Object LastWriteTime -Descending
I use [System.Web.Mail.SmtpMail]::Send($mail) to send messages
It works except, i get only the filenames on the same line, i wish to get the same layout (with the columns…)
$mail = New-Object System.Web.Mail.MailMessage
$mail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpserver”, $server)
$mail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”, $serverPort)
$mail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpusessl”, $true)
$mail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusername”, $credentials.UserName)
$mail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendpassword”, $credentials.Password)
$mail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout”, $timeout / 1000)
$mail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusing”, 2)
$mail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”, 1)
$mail.From = $from
$mail.To = $to
$mail.Subject = $subject
$mail.Body = $content
Perhaps i need to change the type of $mail.Body ?
$mail.Body.GetType()
$content.GetType()
I get :
$mail.Body => name : String , BaseType : System.Object
$content => name : Object , BaseType : System.Array
Any idea ?
Thank you so much guys!