troubleshooting Question

sending email as html - PowerShell function

Avatar of carbonbase
carbonbaseFlag for United Kingdom of Great Britain and Northern Ireland asked on
Powershell
5 Comments1 Solution15 ViewsLast Modified:
Hello, I have the following PowerShell function which sends an email, it sends email as plain text, I would like to update the function so that it sends email as html:

function SendMail ($SMTPserver,$sendermailaddress,$usermailaddress,$mailBody)            
{            
    $smtpServer = $SMTPserver            
    $msg = new-object Net.Mail.MailMessage            
    $smtp = new-object Net.Mail.SmtpClient($smtpServer)            
    $msg.From = $sendermailaddress            
    $msg.To.Add($usermailaddress)            
    $msg.Subject = $mailSubject           
    $msg.Body = $mailBody     
    $smtp.Send($msg)              
}

# call SendMail 

 SendMail $SMTPserver $sendermailaddress $usermailaddress $mailBody          
Thanks in advance.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros