Send mail via Gmail with PowerShell V2's Send-MailMessage

前端 未结 13 1984
一生所求
一生所求 2020-11-30 21:07

I\'m trying to figure out how to use PowerShell V2\'s Send-MailMessage with Gmail.

Here\'s what I have so far.

$ss = New-Object Security         


        
相关标签:
13条回答
  • 2020-11-30 21:32

    I haven't used PowerShell V2's Send-MailMessage, but I have used System.Net.Mail.SMTPClient class in V1 to send messages to a Gmail account for demo purposes. This might be overkill, but I run an SMTP server on my Windows Vista laptop (see this link). If you're in an enterprise you will already have a mail relay server, and this step isn't necessary. Having an SMTP server I'm able to send email to my Gmail account with the following code:

    $smtpmail = [System.Net.Mail.SMTPClient]("127.0.0.1")
    $smtpmail.Send("myacct@gmail.com", "myacct@gmail.com", "Test Message", "Message via local SMTP")
    
    0 讨论(0)
提交回复
热议问题