Advertisement
Dennisaa

Powershell email

Feb 15th, 2014
182
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 someemail@gmail.com -To someemail.code@gmail.com -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 ("someemail.someemail@outlook.com", $x2)
  12. #$outlookCredential = $credential
  13. $outlookCredential = $mycreds
  14.  
  15. $sender = 'someemail@gmail.com' # 'someemail.someemail@outlook.com'
  16. $outlookSender = 'someemail.someemail@outlook.com'
  17. $hotmailSender = 'someemail.someemail@hotmail.co.uk'
  18.  
  19. $Content = "I will be absolutely delighted if this xxx does manage to work, as it will be a first no SSL"
  20. $htmlContent = ConvertTo-Html -Body $Content
  21. $htmlContent
  22. #Send-MailMessage -smtpServer smtp.live.com -Credential $credential -Usessl $Content -from 'someemail.someemail@outlook.com' -to 'someemail@gmail.com' -subject 'Testing'
  23. #Send-MailMessage -smtpServer $emailServer -Credential $googleCredential -Usessl -from $sender -to 'someemail@gmail.com' -subject 'Testing' -BodyAsHtml $Content
  24. Send-MailMessage -smtpServer $outlookServer -Credential $mycreds -Usessl -from $hotmailSender -to 'someemail.someemail@outlook.com' -subject 'Testing' -BodyAsHtml -Body $Content
  25. #Send-MailMessage -smtpServer $emailServer -Credential $googleCredential -Usessl $Content -from $sender -to 'someemail@gmail.com' -subject 'Testing'
  26. #Send-MailMessage -smtpServer $emailServer -Credential $googleCredential -from $sender -to 'someemail@gmail.com' -subject 'Testing' -BodyAsHtml $Content
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement