I'm trying to use code I found to send the contents of a csv file in the body of the e-mail but am having difficulties. Currently this code produces an e-mail with no message in the body. How do I put the content of the file into the body of the e-mail. (I don't want to send the file as an attachment).
$results = Import-Csv c:\drives.txt -header DriveName,HostName,DriveStatus
#* Create new .NET object and assign to variable
$mail = New-Object System.Net.Mail.MailMessage
#* Sender Address
$mail.From = "from@domain.com";
#* Recipient Address
$mail.To.Add("to@domain.com");
#* Message Subject
$mail.Subject = "Drive Status";
#* Message Body
$mail.Body = $results;
#* Connect to your mail server
$smtp = New-Object System.Net.Mail.SmtpClient("mailserver.domain.com");
#* Uncomment line below if authentication is required
#* $smtp.Credentials = New-Object System.Net.NetworkCredential("username", "passwd");
#* Send Email
$smtp.Send($mail);