How to get forms setting by sitefinikty api

Posted by Community Admin on 04-Aug-2018 09:24

How to get forms setting by sitefinikty api

All Replies

Posted by Community Admin on 15-Sep-2015 00:00

Hi All,

I am using sitefinity 8.1.I have created a contact us from in sitefinity forms section.I am adding responses to the forms by using api.So i would like to send a notification email to the mail addresses that configured under the setting section of the form.How can i get that details (response settings) by sitefinity api?

Thanks

Ajai

Posted by Community Admin on 02-Oct-2015 00:00

Hello Ajai,

The following code sample returns the list of emails that are entered through the backend setting:

using System;
using System.Collections.Generic;
using System.Linq;
using Telerik.Sitefinity.Modules.Forms;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Services.Notifications;
  
namespace SitefinityWebApp
    public partial class GetFormSubscribersMailsForm : System.Web.UI.Page
    
        protected void Page_Load(object sender, EventArgs e)
        
           
    var emails = this.GetFormSubscribersMails("MyForm");
        
  
        public List<string> GetFormSubscribersMails(string formTitle)
        
            
    var formsManager = FormsManager.GetManager();
            
    var form = formsManager.GetForms().Where(f=> f.Title == formTitle).FirstOrDefault();
            
    var notificationService = SystemManager.GetNotificationService();
            
    var serviceContext = new ServiceContext("ThisApplicationKey", FormsModule.ModuleName);
  
            
    var subscribedEmails = notificationService.GetSubscribers(serviceContext, form.SubscriptionListId, null)
                
    .Where(s => s.Email == s.ResolveKey)
                
    .Select(s => s.Email)
                
    .ToList();
  
            
    return subscribedEmails;
        
    


I would like to note that this will return only the emails entered in the settings tab in the backend. If you have subscribed  to the form via its Actions menu, this email will not be retrieved.

I hope this helps.

Regards,
Angel Moret
Telerik
 
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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed