Form Builder with email

Posted by Community Admin on 04-Aug-2018 18:45

Form Builder with email

All Replies

Posted by Community Admin on 23-Mar-2012 00:00
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?
Posted by Community Admin on 26-Mar-2012 00:00
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
This thread is closed