Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
149
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. $to = "usersfromgroup@company.com"
  10. $from = "sharepoint@company.com"
  11. $subject = "This is a Test of HTML Email"
  12. $body = "Dear Users"
  13. $body += "We are testing HTML email"
  14. $body += "<html> Click <a href=http://www.google.com>here</a> to open google</html>"
  15. send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml
  16.  
  17. param(
  18. $webUrl = "http://yoursite",
  19. $groupTitle = "your group"
  20. )
  21.  
  22. clear-host
  23.  
  24. function Send-Mail($to){
  25.  
  26. write-host "Sending email to $to..."
  27. $smtp = "SMTP server addresss"
  28. $from = "sharepoint@company.com"
  29. $subject = "This is a Test of HTML Email"
  30. $body = "Dear Users"
  31. $body += "We are testing HTML email"
  32. $body += "<html> Click <a href=http://www.google.com>here</a> to open google</html>"
  33. send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml
  34.  
  35. }
  36.  
  37. Get-SPSite $webUrl | Select -ExpandProperty RootWeb |
  38. Select -ExpandProperty Groups |
  39. Where {$_.Name -eq $groupTitle} |
  40. Select -ExpandProperty Users |
  41. Select * | %{
  42.  
  43. #do stuff here
  44. if($_.Email)
  45. {
  46. Send-Mail $_.Email
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement