#mail server configuration $smtpServer = "" #create the mail message $mail = New-Object System.Net.Mail.MailMessage #set the addresses $MailAddress="" #set the content $mail.Subject = "" $filename="file"
$smtpUser = ""
$smtpPassword = ""
$MailtoAddress=""
$mail.From = New-Object System.Net.Mail.MailAddress($MailAddress)
$mail.To.Add($MailtoAddress)
$mail.Priority = ""
$mail.Body = ""
$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)
powershell send email
最新推荐文章于 2024-12-23 16:13:57 发布
