$smtpServer = "smtp.exmail.qq.com"
$smtpUser = "xxxxx@qq.com"
$smtpPassword = "xxxxxxxxxxxxxx"
#create the mail message
$mail = New-Object System.Net.Mail.MailMessage
#set the addresses
$MailAddress="xxxxx@qq.com"
$MailtoAddress="xxxxx11111111@qq.com"
$mail.From = New-Object System.Net.Mail.MailAddress($MailAddress)
$mail.To.Add($MailtoAddress)
#set the content
$mail.Subject = "Hello PowerShell";
$mail.Priority = "High"
$mail.Body = "Hello Powershell" 
$filename="D:\1.txt"	#add 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)

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-13
  • 2022-01-15
  • 2021-07-16
猜你喜欢
  • 2022-02-05
  • 2022-12-23
  • 2021-07-27
  • 2021-08-31
  • 2021-11-03
  • 2021-07-18
  • 2022-12-23
相关资源
相似解决方案