该脚本使用Exchange插件发送mail。
打开Powershell ISE,复制下面的脚本并添加正确的email地址即可。
Clear
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin -erroraction silentlyContinue
function sendmail_withAttachment {
Param (
#[Parameter(Mandatory=$true)]
[string] $smtpServer = "192.21.168.121",
[string] $From_mail = "Sxxxx@abcd.com",
[string] $to_mail = "Burgess.Liu@abcd.com",
[string] $cc_mail = "Burgess.Liu@abcd.com",
[string] $Subject = "Notification from email server"
)
Write-Host “`n Starting script, Sending Email to Recipients.....” -ForegroundColor Green
$text= ''
$body = ''
$text = "Attached is the email server mailbox report"
$body = "<font color=red><b>$text</b></font><br><br><br><br><br><br><br><br><br><br><b