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

前端 未结 13 2076
一生所求
一生所求 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条回答
  •  猫巷女王i
    2020-11-30 21:14

    After many tests and a long search for solutions, I found a functional and interesting script code at #PSTip Sending emails using your Gmail account:

    $param = @{
        SmtpServer = 'smtp.gmail.com'
        Port = 587
        UseSsl = $true
        Credential  = 'you@gmail.com'
        From = 'you@gmail.com'
        To = 'someone@somewhere.com'
        Subject = 'Sending emails through Gmail with Send-MailMessage'
        Body = "Check out the PowerShellMagazine.com website!"
        Attachments = 'D:\articles.csv'
    }
    
    Send-MailMessage @param
    

提交回复
热议问题