sendMail

Send an email, uses Net.Mail.SmtpClient

Function sendMail{
#SMTP server name
$smtpServer = "smtp.xxxx.com"
#Creating a Mail object
$msg = new-object Net.Mail.MailMessage
#Creating SMTP server object
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
#Email structure
$msg.From = "fromID@xxxx.com"
$msg.ReplyTo = "replyto@xxxx.com"
$msg.To.Add("toID@xxxx.com")
$msg.subject = "My Subject"
$msg.body = "This is the email Body."

#Sending email
$smtp.Send($msg)
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top