Skip to content

Instantly share code, notes, and snippets.

@shane0
Created June 6, 2015 07:51
Show Gist options
  • Save shane0/5512d8900705424365c9 to your computer and use it in GitHub Desktop.
Save shane0/5512d8900705424365c9 to your computer and use it in GitHub Desktop.
powershell send mail using gmail
$param = @{
SmtpServer = 'smtp.gmail.com'
Port = 587
UseSsl = $true
Credential = Get-Credential [email protected]
From = '[email protected]'
To = '[email protected]'
Subject = 'editme'
Body = "editme"
Attachments = c:\file.txt
}
Send-MailMessage @param
@shane0
Copy link
Author

shane0 commented Nov 4, 2018


$filepath = @()
$filepath += 'E:\Folder\file1.txt'
$filepath += 'E:\Folder\file2.txt'
# Write-Host $filepath
foreach($_ in $filepath){
    Write-Host $_
}


$emailparam = @{
    From = '[email protected]'
    To = '[email protected]'
    Attachments = $filepath
}
Write-Host $emailparam.Attachments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment