+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Firing off Email Notifications with New Events or News Items

Firing off Email Notifications with New Events or News Items

4 posts, 0 answered
  1. Terrence
    Terrence avatar
    23 posts
    Registered:
    23 Mar 2009
    07 Jul 2009
    Link to this post
    Hi there

    Is there any way to fire off email notifications to specific users and groups when my user creates a new News or Events item?

    Thanks in advance.

    Best regards
    Terrence
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    07 Jul 2009
    Link to this post
    Hi Terrence,

    Below is a sample code that you can modify and add in Global.asax file.

    Create an event on Application Start. Then add logic for sending the email when an content item has been created. You can try using Newsletters implementation or standard ASP.NET System.Net.Mail

     void Application_Start(object sender, EventArgs e)  
        { 
            // Code that runs on application startup 
            Telerik.Cms.Engine.ContentManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ContentManager_Executing); 
        
     
        } 
     
        void ContentManager_Executing(object sender, Telerik.ExecutingEventArgs e) 
        { 
            if (e.CommandName == "CreateContent"
            { 
                Telerik.Notifications.Newsletters.DataManager dManager = new Telerik.Notifications.Newsletters.DataManager(); 
                IList subscribers = dm.GetSubscribers();  
                 foreach (Telerik.Newsletters.ISubscriber subscriber in subscribers)  
                 {  
                     if(subscriber.Name.Equals("admin")) 
                     { 
                            string body = string.Format("hi,{0}, {1} ,here my body goes", subscriber.FirstName, subscriber.LastName);  
                            string subject = "here is my subject";  
                            string senderName = "here is my name";  
                            string senderAddress = "here is my address";  
                            Telerik.Notifications.Newsletters.NewsletterManager.SendEmail(tolist[], body, subject, senderName, senderAddress); 
                     } 
                 } 
            } 
        } 


    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Terrence
    Terrence avatar
    23 posts
    Registered:
    23 Mar 2009
    07 Jul 2009
    Link to this post
    Hi Ivan

    From your sample code, I can see that you are requesting for the Subscriber list from the Newsletters. So this is for users who are already existing in Sitefinity? How would I be able to add users who are on my global address book groups, e.g. hr@website.com, technical@website.com, etc.

    I would want to be able to key in users' email addresses and not dynamically generate the lists from a predetermined subscriber list.

    Would this be possible?

    Thanks and regards
    Terrence
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    10 Jul 2009
    Link to this post
    Hi Terrence,

    So this is for users who are already existing in Sitefinity
    No, these are users Subscribed for the Newsletters. These are the same users in your Newsletter module.

    How would I be able to add users who are on my global address book groups
    You can either import these users to the Newsletter module, or just supply them in the tolist in the code:
    tolist.Add(mail1); 
    tolist.Add(mail2); 
    .. 

    You can also use the .NET SMTP and Mail classes with predefined list. This was just an example with the Newsletters module.

    Regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
4 posts, 0 answered