How to get forms setting by sitefinikty api
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
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;