powershell sending email alert automatically attaches winmail.dat
Posted on 2014-08-21
We are using powershell scripts to email out notifications for windows server 2012 backups. However when sending the message, it is attaching a file winmail.dat automatically, which is causing some email providers to reject the message thinking its spam / virus related. How can we stop this attachment from sending? Here is the script we are using:
# Set up variables
$SmtpServer = "SMTP SERVER ADDRESS"
$SmtpPort = 25
$FromEmail = "FROM EMAIL ADDRESS"
$ToEmail = "TO EMAIL ADDRESS"
# Construct and send email
$SmtpClient = new-object system.net.mail.smtpClient
$Msg = new-object Net.Mail.MailMessage
$SmtpClient.host = $SmtpServer
$SmtpClient.Port = $SmtpPort
$computer = gc env:computername
$Msg.From = $FromEmail
$Msg.Subject = "Company Name Windows Server Backup Successful on " +$Computer + ""
$Msg.Body = "The backup for " +$Computer+" has completed successfully."