More in this section

Forums / Bugs & Issues / Form Builder with email

Form Builder with email

2 posts, 0 answered
  1. Pavliks
    Pavliks avatar
    68 posts
    Registered:
    06 Apr 2010
    23 Mar 2012
    Link to this post
    Does this exist in Sitefinity 4.4? Nice to have forms but how come it can't send emails? Is there a control available in the market place? or an example how how to do this otherwise?
  2. Grace Hallwachs
    Grace Hallwachs avatar
    144 posts
    Registered:
    03 Nov 2014
    26 Mar 2012
    Link to this post
    Hello Nimit,

    Thank you for contacting support.

    There is tutorial plus sample project available in this blog post for forms e-mail notifications.

    For the subscribe form:

    using System;
     
    using System.Collections.Generic;
     
    using System.Linq;
     
    using System.Web;
     
    using System.Net.Mail;
     
    using Telerik.Sitefinity.Configuration;
     
    using Telerik.Sitefinity.Services;
     
    using System.Text;
     
    using Telerik.Sitefinity.Web.Mail;
     
    using System.ComponentModel;
     
      
     
    namespace SitefinityWebApp
     
    {
     
        public class Class1 : Telerik.Sitefinity.Modules.Newsletters.Web.UI.Public.SubscribeForm
     
        {
     
              
     
      
     
            protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
     
            {
     
                base.InitializeControls(container);
     
                this.SubscribeButton.Click += new EventHandler(Class1_BeforeFormAction);
     
            }
     
      
     
            private void Class1_BeforeFormAction(object sender, EventArgs e)
     
            {          
     
                var smtpSettings = Config.Get<SystemConfig>().SmtpSettings; 
     
                MailMessage message = new MailMessage();
     
                message.From = new MailAddress(smtpSettings.DefaultSenderEmailAddress);
     
                message.To.Add(new MailAddress("user@telerik.com"));
     
                StringBuilder sb = new StringBuilder();
     
                sb.AppendFormat("You have one new form response on  form. The response is sent from IP address");
     
                message.Subject = "Forms notification";
     
                message.Body = sb.ToString();
     
                message.IsBodyHtml = true;
     
                message.BodyEncoding = Encoding.Unicode;
     
                message.SubjectEncoding = Encoding.Unicode;
     
                EmailSender.Get().Send(message);
     
            }
     
        }
     
    }

    Create a class in your solution and create a custom subscribe form as in the sample above. Register the new control in Administration->Settings->Advanced->Toolboxes->PageControls->Sections->(choose section)->Create new and enter (namespace.class) of the class from the sample:
    Controll type: SitefinityWebApp.Class1 (in my case, I encourage you to create better naming)
    Name: Class1
    Title: Custom Subscribe Form

    To receive the e-mail you mut have valid SMTP settings configured in Administration->Settings->Advanced->System->SMTP.

    Please let us know if you have anymore questions.

    Greetings,
    Grace Hallwachs
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered