Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How to generate SPAlert from some list to specific user with c# who doesn't subscribe that list? User cannot be added to list subscribers.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

Once you have written your own implementation of OnNotification() you can send the email to whomever you would like. Alert customization

It is possible to send a user an alert without having them be a subscriber, but it is a poor workaround to a better design alternative of empowering the user to control their own alerts.

Here are the properties of an alert. The SPAlert item is a store of a few specific properties and then a reference to 3 other records solving the many:many:many problem by turning them into one:many. See the starred items below:

    Title             : Tasks
    AlertTemplateName : SPAlertTemplateType.Tasks.Ext
  * AlertTemplate     : SPAlertTemplate Name=SPAlertTemplateType.Tasks.Ext
    Filter            :
    Properties        : {mobileurl, filterindex, siteurl, eventtypeindex...}
    ID                : f908d7a0-cd2a-4257-a6fb-61c3e31a0b36
  * ListID            : 50e97c9d-57f6-4440-91bc-9d4c23b97147
    MatchId           :
    ItemID            :
    ListUrl           : Lists/Tasks
    List              : Tasks
    Item              :
    AlwaysNotify      : False
    DeliveryChannels  : Email
    AlertType         : List
    EventType         : All
    EventTypeBitmask  : -1
    AlertFrequency    : Daily
    AlertTime         : 10/24/2012 12:30:24 PM
    Status            : On
    User              : NotMyCompany\ghangas
  * UserId            : 1
    DynamicRecipient  :

The whole basis for the alerts system is to match up a list : alert template : Site Collection User. Your question asks if you can make a stool with only 2 legs. Naturally, the answer is yes, well kind of... You could make one with your service account as a user and catch that in your event receiver and then replace the email address

    if (alertHandler.headers["to"] == "ServiceAccountAsAStandInForAnEndUser@NotMyCompany.com")
    {
         alertHandler.headers["to"] = "ILoveSpam@NotMyCompany.com"
    }

    SPUtility.SendEmail(web, alertHandler.headers, alertHandler.body); 

I would look at the requirements closely and see if this is a code solution to a people problem and consider drawing the line between people and code in a different place.

share|improve this answer
    
Hey it is cool! I will add some dumb domain user and set subscription to the list and I will extend my cyrrent OnNotification method! Thanks a lot... –  marcinn Oct 24 '12 at 6:48
add comment

SharePoint alerts do not have anything that would allow this. However, you could do this via SharePoint Designer Workflow as long as you don't mind the format of the message being a little bit different than a standard alert

share|improve this answer
    
In my requirements customized alert template should be used which is used for standard alert procedure (format of message mertters). –  marcinn Oct 23 '12 at 20:42
    
If you must use the Alert Template then you are going to be getting familiar with implementing your own IAlertNotifyHandler. Check out this for more details : blogs.msdn.com/b/sharepointdeveloperdocs/archive/2007/12/14/… –  Dave Wise Oct 23 '12 at 20:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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