Skip To Content

Customize Kentico to Provide Form Response Emails with Rich Marketing Content

Kentico provides powerful online marketing capabilities that can be overlooked if one is not familiar with how its features can be customized and integrated. When comparing Kentico with one-size-fits-all platforms, it’s important to remember that Kentico excels when it is tailored to an organization’s unique business needs. Today, I will show you one such powerful customization you may not know about: how you can use Kentico’s Email Marketing module to send form response emails to customers that include rich marketing content.

Kentico’s Autoresponder

The Kentico Forms module includes an out-of-the-box AutoResponder feature that provides an easy way to send simple emails in response to form submissions. This feature offers a rich-text email authoring environment with basic field substitution. It is a great fit if a marketing team’s content needs are simple, since it is readily available and easy to use.

Kentico CMS Admin forms autoresponder

However, marketers often want to take every advantage of a user’s attention and there is no better opportunity to start a conversation than when a user submits an online form. Since the user is expecting a follow-up email, marketers often want to extend the conversation beyond a simple thank-you message, by providing additional content like product recommendations. If marketers assume they need to use Kentico’s AutoResponder to create emails that include rich marketing content, they may be disappointed. The great news is that although not immediately obvious, when leveraged properly, Kentico’s Email Marketing module, including all its available templates and widgets, can be used to send these compelling form response emails.

Email Marketing Email Builder

Kentico’s Email Marketing module provides an email builder with templates and widgets, providing a powerful tool to create emails with compelling designs and rich content. For example, the email builder makes it easy to send an email that provides a card-based layout of interesting content like products related to the recipient’s interests. Marketers can use every form submission as an opportunity to engage users with more information.

email marketing email builder screen

To realize the Email Marketing module’s full potential, it is important to understand how Kentico’s features can combine to provide enhanced capabilities. In this case, the email builder can be used to send response emails by combining Kentico’s Forms, Email Marketing, and Marketing Automation modules, with the addition of a little bit of glue: a custom macro method.

Putting it all together

To help you understand Kentico’s capabilities, let’s walk through an example of creating an online form that triggers an email response from Kentico’s Email Marketing module. We’ll create a form from which a user can request a free sample of dog snacks from Oliver’s Treats. However, instead of simply providing an email confirming the request – something that would be easy to do with the Autoresponder feature – we’ll respond with a marketing email that also provides rich information about other treats that Oliver recommends.

For example, instead of providing a simple confirmation like this:

sample email

We’ll use the opportunity to engage the user with additional personalized content:

sample email with widgets

To achieve this, we only need one small piece of custom code, a custom macro method that retrieves a recipient’s form data. Once that macro method is created, we’ll be able to use Kentico’s out-of-the-box features to create an online form, a campaign email to provide the follow-up, and a marketing automation process to send it whenever the form is submitted.

Create a macro method

The first step, the little bit of ‘glue’ required to make the solution work, is to create a custom macro method. The method uses the activities logged for the recipient contact in order to find the recipient’s form submission, then utilize the data in macro expressions.

The macro method is registered for the ContactInfo type, so that email widgets can call it for each recipient contact. The second parameter is the ID of the form from which the data should be returned. After validating the parameters, the method uses the ActivityInfoProvider to find a “bizformsubmit” activity with an ActivityContactID matching the provided contact and an ActivityItemID matching the provided FormID.

The ActivityInfo object provides the form’s ItemID using the ActivityItemDetailID property, which allows returning the BizFormItem from the BizFormItemProvider.

Here’s a simplified version of this macro method including its container class. (In real life, this method should use the Kentico caching API to improve performance.)

using System.Linq;

using CMS;

using CMS.Activities;

using CMS.ContactManagement;

using CMS.DataEngine;

using CMS.Helpers;

using CMS.MacroEngine;

using CMS.OnlineForms;

using OliversTreats.MacroMethods;

// Makes all methods in the 'ContactFormContentMacroMethods' container class available for ContactInfo objects

[assembly: RegisterExtension(typeof(ContactFormContentMacroMethods), typeof(ContactInfo))]

namespace OliversTreats.MacroMethods


    /// <summary>

    /// Provide methods that can be used from within Kentico macros to provide online form content in marketing emails.

    /// </summary>

    public sealed class ContactFormContentMacroMethods : MacroMethodContainer


        /// <summary>

        /// With the provided ContactInfo and FormID, lookup the form submission provided by the contact and return the

        /// form item to provide the contact's submitted form data. This object can be used to provide the form data

        /// to the macro context of Email Marketing widgets.

        /// </summary>

        /// <param name="context"></param>

        /// <param name="parameters"></param>

        /// <returns>Return the BizFormItem that provides the contact's submitted form data. </returns>


                     "Looks up the last form data for the provided contact, and returns the form data to be used in a macro context.",


         MacroMethodParam(0, "contact", typeof(ContactInfo), "The ContactInfo of the email recipient."),

         MacroMethodParam(1, "formId", typeof(int), "The FormID from which to look up the contact's form submission.")]

        public static object GetContactFormItem(EvaluationContext context, params object[] parameters)


            if (parameters.Length < 2)


                return null;


            ContactInfo contactInfo = null;

            if (parameters[0] is ContactInfo)


                contactInfo = (ContactInfo)parameters[0];


            var formId = ValidationHelper.GetInteger(parameters[1], 0);

            if ((contactInfo == null) || (formId == 0))


                return null;


            // Use Kentico's activity tracking to get the "form submission" activity associated to

            // this contact's submission of the specified form.

            // This will allow us to get the ActivityItemDetailID, which is the ID of the form data record.

            // The ActivityItemID is the Form ID.

            var formSubmissionActivityInfo = ActivityInfoProvider.GetActivities()

                 .WhereEquals("ActivityContactID", contactInfo.ContactID)

                 .WhereEquals("ActivityType", "bizformsubmit")

                 .WhereEquals("ActivityItemID ", formId)




            if ((formSubmissionActivityInfo == null) || (formSubmissionActivityInfo.ActivityItemDetailID == 0))


                return null;


            var formItemId = formSubmissionActivityInfo.ActivityItemDetailID;

            // Get the Kentico BizFormInfo and the DataClassInfo that defines

            // the fields in the form.

            var bizFormInfo = BizFormInfoProvider.GetBizFormInfo(formId);

            if (bizFormInfo == null)


                return null;


            var dataClassName = DataClassInfoProvider.GetClassName(bizFormInfo.FormClassID);

            // Finally, get the actual form data record that the subscriber submitted.

            var bizFormItem = BizFormItemProvider.GetItem(formItemId, dataClassName);

            return bizFormItem;




After creating and registering the macro method, you can test it in Kentico’s Macros Console. Here’s an example of using it to call the GetContactFormItem method:

GlobalObjects.Contacts.Where("ContactEmail = 'oliver@server.local'").FirstItem.GetContactFormItem(2)
Kentico cms admin for evaluation input

Create the form

After creating the custom macro method, a marketer can create an online form. However, instead of using the Autoresponder feature to send a response email, she can use the full-featured Email Marketing module to send rich response emails. To continue our scenario, let’s create a form to allow customers to request a free sample from Oliver’s Treats.

The first step is to create the new online form and its custom fields. Make sure you ask for the user’s email address, mailing address, and treat preference.

Kentico admin form builder

Finally, make sure the form’s email field maps to the contact email field, in the form’s Contact mapping tab. This will ensure that a contact with a valid email address is created when the form is submitted. Without this step, Kentico’s Marketing Automation module will not be able to send a response email to the user.

Kentico admin form contact mapping form

Creating an Email Marketing Widget

While employing the custom macro method, it is easy to create a widget that uses the form data, within Kentico’s Email Marketing module. To demonstrate, let’s create a widget named “Form Content” that allows a marketer to enter rich text with macro expressions that use the form data. The widget will require one property to allow marketers to enter rich text and another to specify the online form. Let’s call these properties “FormID” and “EmailText.” To create a property that allows selecting an online form, use the BizForm selector control.

Kentico Admin form content screen

To use form fields in the email widget, add a macro to the Widget editor. The macro should call the custom macro method using the ContactInfo associated with email recipient and the FormID selected in the widget’s custom property. The returned BizFormItem should be held in a macro variable so that it is available in the macro context.


form = Advanced.ContactInfo.GetContactFormItem(FormID);



<div class="richtext-block">

{% EmailText == String.Empty ? "Enter your text and some form fields" : EmailText #%}


By creating a macro variable named “form” holding the BizFormItem, email authors will be able to enter macro expressions using the fields in the form, as illustrated below.

Kentico admin form content screen

Composing the email

With the custom macro method and email widget configured, marketers have everything they need to compose response emails for online forms, using Kentico’s Email Marketing module with its robust template and widget capabilities. The Email Marketing module allows marketers to include content from other widgets by simply dragging them onto the email’s design surface. Imagine providing the power of this Form Content widget, with additional widgets to provide a compelling banner, recommended products, and related information.

I recommend creating an email campaign dedicated to organizing emails used as form responses:

Kentico admin email feeds

Within the email campaign, create an email for each form that requires an automated email response:

Kentico Admin email listing

Creating a Marketing Automation Workflow

After a marketer creates an online form and a response email in the Email Marketing module, a new process needs to be created in the Marketing Automation module in order to tie the form and response email together. To do this, create a new process named “Free sample response” and set the process to always start as a new instance:

Kentico admin response set up

Next, create a trigger for the process, so it starts whenever a contact submits the “Free Treats” form:

Kentico admin trigger set-up

Finally, create the steps for the process, so that when it starts, it uses the Send marketing email action to send the response email:

Kentico admin marketing automation flow chart

Configure the Send marketing email action to send the desired email:

Kentico admin step set-up

Now, simply by leveraging a small custom macro method, whenever an online form is submitted, a Marketing Automation process will send a follow-up email that combines form data with additional compelling content.

In Summary

I hope this example of integrating several of Kentico’s modules to provide rich form-response emails helps you realize the awesome power of Kentico’s online marketing features. Kentico is a platform intended to be tailored for business-specific needs, so it is helpful to understand just how broad a scope of features and customization options it offers. So, if you take a close look at what Kentico can do with a little bit of customization, it just may turn out to be the best fit for your marketing team’s online needs.

Have questions on how to get the most out of your Kentico implementation? Drop me a line on Twitter (@HeyMikeWills), or view my other articles here.