1

I am working in SharePoint 2013 and have a requirement to create a timer job that will keep sending notifications to users in a recursive manner.

I have referred this article which describes the basics of creating a timer job. I need to query a list and send a notification email to the person to whom the task is assigned. This has to be done on a daily basis.

I have tried accomplishing this using a workflow and alerts but it is not possible so the only accomplishing this is by a timer job. It would helpful if any body would be able to guide me regarding how to query the items.

  • what are the list columns (show internal names). What is the condition? I mean when you wish to send email – Atish Dipongkor - MVP Sep 24 '15 at 5:55
  • The column I wish to check is called Resolved. This is a yes/no column. If the value is No then I wish to email the person in the column called "HSemail". This is a forms library (InfoPath), just in case that makes a difference in the code over a document library – Penfold Sep 24 '15 at 20:16
0

You would need to create a timer job that would be triggered on a daily basis. The following code will help you to create timer job that will run on daily basis:

SPDailySchedule tempSchedule = new SPDailySchedule();
tempSchedule.BeginHour = 23;
tempSchedule.BeginMinute=5;
tempSchedule.BeginSecond = 0;
tempSchedule.EndSecond = 15;
tempSchedule.EndMinute = 5;
tempSchedule.EndHour = 23;
tempJob.Schedule = schedule;
tempJob.Update();

You would need to use a CAML query on your list to get the list of users to whom the task is assigned. Once you get that you would also need to get their email id to send the mail. Add all these details to the

Execute()

method of the timer job.

I hope this helps.

  • You have removed the user's link while editing! – Atish Dipongkor - MVP Sep 24 '15 at 9:23
  • I have some code that I have glued together from examples. But I am getting an error on this line of the CreateJob method in the event receiver. 'FindUnresolvedIncidents job = new FindUnresolvedIncidents(JobName, site);' Gives the error: Argument 2: cannot convert from 'Microsoft.SharePoint.Administration.SPWebApplication' to 'Microsoft.SharePoint.Administration.SPService' It is calling some code in the class file 'public FindUnresolvedIncidents(string jobName, SPService service): base(jobName, service, null, SPJobLockType.None)' – Penfold Sep 30 '15 at 21:07
  • Apologies for the horrible formatting, I struggled to get everything I needed to say in the amount of characters permitted... and every time I typed enter to put in a line break it kept submitting the comment so I had to edit it to put the rest in. – Penfold Sep 30 '15 at 21:09
  • Update to my comment. I have found the reason for my error, I was missing the 3rd required constructor: public FindUnresolvedIncidents(string jobName, SPWebApplication webapplication): base(jobName, webapplication, null, SPJobLockType.None) – Penfold Sep 30 '15 at 22:40

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.