Single Blog

Send-SMTPmail Using Powercli

Below function should be include in the script:
function Send-SMTPmail($to, $from, $subject, $smtpserver, $body, $attachment) {
$mailer = new-object Net.Mail.SMTPclient($smtpserver)
$msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)
$msg.IsBodyHTML = $true
$attachment = new-object Net.Mail.Attachment($attachment)
$msg.attachments.add($attachment)
$mailer.send($msg)
}

Command which need to use in the script after function declaration
send-SMTPmail $EmailTo $EmailFrom “$VISRV vCheck Report” $SMTPSRV -body “$VISRV vCheck Report” -attachment “$Filename”

Comments (0)

Post a Comment