Advertisement
Guest User

Untitled

a guest
Jan 6th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. $recipients = "<user1@company.com>", "<group1@company.com>", "<group2@company.com>"
  2.  
  3. #below try/catch lines are just to make sure the list exists, you don't actually need it!
  4. Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0
  5. try
  6. {
  7. $web = Get-SPWeb http://spwebapp1/sites/team
  8. $list = $web.GetListFromUrl("http://spwebapp1/sites/team/Lists/List1/AllItems.aspx")
  9. $fullUrl = $web.Site.Url + $list.DefaultViewUrl.Remove(0,1)
  10. }
  11. catch{
  12. Write-Host "it broke!"
  13. return
  14. }
  15.  
  16. #Or you could just set $fullUrl to a static string
  17. $fullUrl = "http://spwebapp1/sites/team/Lists/List1/AllItems.aspx"
  18.  
  19. #And this sends out the mail to the specified SmtpServer
  20. Send-MailMessage -From "sharepoint@company.com" -To $recipients -Subject "Happy Monday!" -BodyAsHtml "Here's a <a href='$($fullUrl)'>link!</a>" -SmtpServer mail.company.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement