这行得通,但是...
$EmailFrom = "vsphere@nasa.gov"
$EmailTo = "userwithOLDsnapshot@nasa.gov"
$Subject = "Notification"
$Body = "this is a notification for your snapshot"
$SMTPServer = "smtp.gmail.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("username", "password");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
反正有没有用凭证商店做这个?以明文形式在脚本中嵌入凭据是不行的。