您的位置:首页 > 运维架构 > Shell

powershell send email

2011-01-12 17:31 232 查看
#mail server configuration

$smtpServer = ""
$smtpUser = ""
$smtpPassword = ""

#create the mail message

$mail = New-Object System.Net.Mail.MailMessage

#set the addresses

$MailAddress=""
$MailtoAddress=""
$mail.From = New-Object System.Net.Mail.MailAddress($MailAddress)
$mail.To.Add($MailtoAddress)

#set the content

$mail.Subject = ""
$mail.Priority = ""
$mail.Body = ""

$filename="file"
$attachment = new-Object System.Net.Mail.Attachment($filename)
$mail.Attachments.Add($attachment)

#send the message
$smtp = New-Object System.Net.Mail.SmtpClient -argumentList $smtpServer
$smtp.Credentials = New-Object System.Net.NetworkCredential -argumentList $smtpUser,$smtpPassword
$smtp.Send($mail)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: