I have a list of (email) objects which has a lookup field. When an email is received in my document library, I have added code to the EmailEventReceiver to see if the email address matches an applicant that exists in another list. If a match is found (ie if the incoming email address matches a saved email address of an applicant), then I assign the applicantID to the applicant lookup field of the email object. All of that works well and hunky dory.

My next challenge is to either automatically or manually run the same type of code periodically on any email objects that are yet to be assigned. In other words, if I receive an email from an applicant that doesnt yet exist, but I have since receiving the email created an applicant, to then update all the email items in the list with his association.

I thought, in the time being, to add a 'button' on the page which when clicked would then run the same type of C# code on the list.

Is this possible? Is there a better way to do this?


  • Kindly specify the version of SharePoint as a tag you are using.
    – Pradip R.
    May 4, 2015 at 9:58
  • If you are using SharePoint 2013 version then Yes that is possible. You can use CSR here. Which adds a custom button to the list item. That button has ajax post which execute your C# code. Make sure you go through with CSR Examples: code.msdn.microsoft.com/office/…
    – Pradip R.
    May 4, 2015 at 10:06

1 Answer 1


You have several options to achieve this:

  1. Create a custom action with server-side control. You can create a ribbon custom action, add it to list and handle the code in your code behind. Here is the sample of such custom action.
  2. Create a custom action with JavaScript using JQuery AJAX call to HTTP endpoint, that executes your C# code. Here is the sample using HTTP endpoint (this way is the easiest and fastest), but also you can have your own web services (asmx or svc) or event ASPC page. You can read about differences in that article series. I would recommend this way.
  3. Create a site workflow using Visual Studio (or maybe even SharePoint Designer), that could make this scenario. If you really would like to use the same code, you can create custom code activity. On the other hand you could try to make it work in declarative way. Overall, this could be a kind of complex way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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