2020年3月13日 星期五

Powershell: 寄送email並夾帶附件

語法單純(與Python相比):

Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject -Body $Body -SmtpServer $SMTPServer -port $SMTPPort -UseSsl -Credential (Get-Credential) -Attachments $Attachment –DeliveryNotificationOption OnSuccess

如果要寄給多個人, 以逗號分隔, 例如:

  $To = "email_1","email_2"

要帶多個附件也是以逗號分隔.


Ref:
1.How to Send an Email Using Windows PowerShell
https://www.makeuseof.com/tag/send-email-windows-powershell/

2.Send-MailMessage
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/send-mailmessage?view=powershell-7

3.Powershell 學習筆記
https://blog.darkthread.net/blog/powershell-learning-notes/

4.PowerShell® Notes for Professionals book
https://books.goalkicker.com/PowerShellBook/

5.python中傳送郵件(普通文字檔案、附件、圖片等)
https://www.itread01.com/content/1544639973.html

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。