Dennisaa

Powershell email

Feb 15th, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $gmailServer = "smtp.gmail.com"
  2. $outlookServer = "smtp.live.com"
  3.  
  4. #Send-MailMessage -SmtpServer $emailServer -Subject "asdfaf" -From [email protected] -To [email protected] -Body "This is a test" -UseSsl true
  5. #$credential = Get-Credential
  6. #$googleCredential = Get-Credential
  7. #$secpasswd = ConvertTo-SecureString "ThePassword" -AsPlainText -Force
  8. $encrypted = ConvertFrom-SecureString -SecureString $secpasswd
  9. $encrypted
  10. $x2 = ConvertTo-SecureString -String $encrypted
  11. $mycreds = New-Object System.Management.Automation.PSCredential ("[email protected]", $x2)
  12. #$outlookCredential = $credential
  13. $outlookCredential = $mycreds
  14.  
  15. $outlookSender = '[email protected]'
  16. $hotmailSender = '[email protected]'
  17.  
  18. $Content = "I will be absolutely delighted if this xxx does manage to work, as it will be a first no SSL"
  19. $htmlContent = ConvertTo-Html -Body $Content
  20. $htmlContent
  21. #Send-MailMessage -smtpServer smtp.live.com -Credential $credential -Usessl $Content -from '[email protected]' -to '[email protected]' -subject 'Testing'
  22. #Send-MailMessage -smtpServer $emailServer -Credential $googleCredential -Usessl -from $sender -to '[email protected]' -subject 'Testing' -BodyAsHtml $Content
  23. Send-MailMessage -smtpServer $outlookServer -Credential $mycreds -Usessl -from $hotmailSender -to '[email protected]' -subject 'Testing' -BodyAsHtml -Body $Content
  24. #Send-MailMessage -smtpServer $emailServer -Credential $googleCredential -Usessl $Content -from $sender -to '[email protected]' -subject 'Testing'
  25. #Send-MailMessage -smtpServer $emailServer -Credential $googleCredential -from $sender -to '[email protected]' -subject 'Testing' -BodyAsHtml $Content
Advertisement
Add Comment
Please, Sign In to add comment