Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. Get-SPSite https://SitecollectionURL |
  2. Select -ExpandProperty RootWeb |
  3. Select -ExpandProperty Groups |
  4. Where {$_.Name -EQ "SP Group Name"} |
  5. Select -ExpandProperty Users |
  6. Select Email
  7.  
  8. $smtp = "SMTP server addresss"
  9. $subject = "This is a Test of HTML Email"
  10. $body = "Dear Users"
  11. $body += "We are testing HTML email"
  12. $body += "<html> Click <a href=http://www.google.com>here</a> to open google</html>"
  13. send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml
  14.  
  15. param(
  16. $webUrl = "http://yoursite",
  17. $groupTitle = "your group"
  18. )
  19.  
  20. clear-host
  21.  
  22. function Send-Mail($to){
  23.  
  24. write-host "Sending email to $to..."
  25. $smtp = "SMTP server addresss"
  26. $from = "[email protected]"
  27. $subject = "This is a Test of HTML Email"
  28. $body = "Dear Users"
  29. $body += "We are testing HTML email"
  30. $body += "<html> Click <a href=http://www.google.com>here</a> to open google</html>"
  31. send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml
  32.  
  33. }
  34.  
  35. Get-SPSite $webUrl | Select -ExpandProperty RootWeb |
  36. Select -ExpandProperty Groups |
  37. Where {$_.Name -eq $groupTitle} |
  38. Select -ExpandProperty Users |
  39. Select * | %{
  40.  
  41. #do stuff here
  42. if($_.Email)
  43. {
  44. Send-Mail $_.Email
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement