Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Get-SPSite https://SitecollectionURL |
- Select -ExpandProperty RootWeb |
- Select -ExpandProperty Groups |
- Where {$_.Name -EQ "SP Group Name"} |
- Select -ExpandProperty Users |
- Select Email
- $smtp = "SMTP server addresss"
- $to = "usersfromgroup@company.com"
- $from = "sharepoint@company.com"
- $subject = "This is a Test of HTML Email"
- $body = "Dear Users"
- $body += "We are testing HTML email"
- $body += "<html> Click <a href=http://www.google.com>here</a> to open google</html>"
- send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml
- param(
- $webUrl = "http://yoursite",
- $groupTitle = "your group"
- )
- clear-host
- function Send-Mail($to){
- write-host "Sending email to $to..."
- $smtp = "SMTP server addresss"
- $from = "sharepoint@company.com"
- $subject = "This is a Test of HTML Email"
- $body = "Dear Users"
- $body += "We are testing HTML email"
- $body += "<html> Click <a href=http://www.google.com>here</a> to open google</html>"
- send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml
- }
- Get-SPSite $webUrl | Select -ExpandProperty RootWeb |
- Select -ExpandProperty Groups |
- Where {$_.Name -eq $groupTitle} |
- Select -ExpandProperty Users |
- Select * | %{
- #do stuff here
- if($_.Email)
- {
- Send-Mail $_.Email
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement