How to send form notifications to different emails based on field values.

   —   
This article describes how to send form notifications to different email addresses, based on a value selected by the user at form submission. For instance, the value of a dropdown could be used to direct notifications to different email addresses.
There may be cases where the notifications received for form submissions or new user registrations should be handled by separate departments. For instance, if someone submits a form that's used for general questions and you offer a category dropdown with values such as General, Sales, Support, you may wish to send the notifications to corresponding email addresses.

The first step is to create a field for your form with the correct labels and values. You would add this to your form's layout. The field should be a dropdown list. For instance, if I have a dropdown list field called "Category", I might define it like this:

Value;Display Name
info@company.com;General
sales@company.com;Sales
support@company.com;Support

Now, from the Notification E-mail tab for your form, you can enter a macro referencing the field name. Go to CMS Desk -> Tools -> Forms and edit your form. From the Notification E-mail tab, set the value of the "To e-mail" field to:

{% category % }

Now the value of our Category field is used to populate the “to” email address. If the user has selected "Sales", a notification will be sent to sales@company.com.
-ag-


Applies to: Kentico CMS 6.x, and 7.x
Share this article on   LinkedIn