I am looking to create a timer job that would run weekly and send an automated mail to seven different groups of users very start day of the week.

  • For example week starts with Monday every Monday they should be getting email with a link to one of the list.
  • This is weekly process
  • Once the week ends it stops and again on Monday a email with link will be sent
  • I have never written a timer job and being a learner i just need some tips and guidance on how to approach on this.
  • I am using SharePoint 2010 and visual studio 2010.

1 Answer 1


While I'm not trying to discourage learning, I think it would be best to create a PowerShell script and make this a Scheduled Task, instead. You'll have more flexibility to modify the script as well as modify the schedule. Since it is outside of the Timer Service, there is also no potential for bad code to crash the Timer Service.

$recipients = "<user1@company.com>", "<group1@company.com>", "<group2@company.com>"

#below try/catch lines are just to make sure the list exists, you don't actually need it!
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0
    $web = Get-SPWeb http://spwebapp1/sites/team
    $list = $web.GetListFromUrl("http://spwebapp1/sites/team/Lists/List1/AllItems.aspx")
    $fullUrl = $web.Site.Url + $list.DefaultViewUrl.Remove(0,1)
    Write-Host "it broke!"

#Or you could just set $fullUrl to a static string
$fullUrl = "http://spwebapp1/sites/team/Lists/List1/AllItems.aspx"

#And this sends out the mail to the specified SmtpServer
Send-MailMessage -From "sharepoint@company.com" -To $recipients -Subject "Happy Monday!" -BodyAsHtml "Here's a <a href='$($fullUrl)'>link!</a>" -SmtpServer mail.company.com

At that point, you can set up a Windows Scheduled Task to run at your desired date/time. Note that if you decide to use the SharePoint bits of the above script, you will need to run the task as a user who has rights to the site, in addition to setting the option to "Run with highest privileges". This also requires Local Administrator rights on the server.

  • hi trevor could you suggest me some links to start up on this?or a snippet
    – SPLearner
    Jan 6, 2016 at 19:13
  • Is the link the same every week? Is it to a List, Site, or Item? Based on that info, I can give you an example.
    – Trevor Seward
    Jan 6, 2016 at 19:16
  • 1
    Apart from what Trevor suggested,you can learn details of timer job from simple-talk.com/dotnet/.net-tools/…
    – user13408
    Jan 7, 2016 at 3:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.