Powershell 发送邮件代码

$pw = import-csv D:\pw.csv
$user = "junjianyang@focuswin.cn"
$PWord = ConvertTo-SecureString –String "password" –AsPlainText -Force
$mycreds = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $PWord
$pw | ForEach-Object {Send-MailMessage -Encoding utf8 -To $_.to -From junjianyang@focuswin.cn -Subject "Test测试" -Body ("密码是:" + $_.pw) -Credential $mycreds -SmtpServer smtp.office365.com -DeliveryNotificationOption Never -BodyAsHtml -UseSsl -port 587}

 

国际版的office 365 

posted @ 2018-05-29 15:22  Jupiter077  阅读(658)  评论(0编辑  收藏  举报