#定义邮件服务器
$smtpServer = "mail.163.com"
$smtpUser = "sys@163.com"
$smtpPassword = "password"
$mail = New-Object System.Net.Mail.MailMessage

#定义发件人邮箱地址、收件人邮箱地址
$MailAddress="sys@163.com"
$MailtoAddress="ll@163.com"
$mail.From = New-Object System.Net.Mail.MailAddress($MailAddress)
$mail.To.Add($MailtoAddress)


 #定义邮件标题、优先级和正文、附件
$mail.Subject = "test";
$mail.Priority  = "High"
$mail.Body = "testttt"
$Afile = "e:\CSV-Export.rar"
$smtp = New-Object System.Net.Mail.SmtpClient -argumentList $smtpServer
$smtp.Credentials = New-Object System.Net.NetworkCredential -argumentList $smtpUser,$smtpPassword
$attachment = new-Object System.Net.Mail.Attachment -ArgumentList $Afile
$mail.Attachments.Add($attachment)
$smtp.Send($mail)
$attachment.dispose()

 

相关文章:

  • 2021-09-01
  • 2022-12-23
  • 2021-05-14
  • 2021-08-17
  • 2021-10-20
  • 2021-10-15
  • 2021-11-09
  • 2022-01-08
猜你喜欢
  • 2022-12-23
  • 2021-04-16
  • 2022-03-08
  • 2021-07-13
  • 2022-01-18
  • 2021-04-09
相关资源
相似解决方案