WFFM have its own send email action but we can’t change the email field during run time. Suppose we have a category dropdown and based on category WFFM need to send email to different group. So if category is “Marketing” is selected then email should go to the marketing group and if category “HR” is selected then email should go to the human resource group.
To resolve this kind of problem we have created a custom droplist field which is just copy of existing droplist field. Motive behind creating this duplicate field is just to differentiate default dropdown field for our custom save action. Datasource for this field should be a template which have all required email field such as TO, CC, BCC, Subject etc.
We have created a custom save action for sending email based on selection by navigating sitecore/System/Modules/Web Forms for Marketers/Settings/Actions/Save Actions
You need to right click on the save actions item and select save action button from insert option, it will open the dialog and you need to enter the name of the action.
In the new save action we need to fill the Assembly and Class fields by entering the name of the assembly and class name.
We will also use the parameter field for SMTP information for sending custom email by using this SMTP information.
We are inheriting the Sitecore.WFFM.Actions.Base.WffmSaveAction abstract class and overriding the Execute method.
using Log = Sitecore.Diagnostics.Log;
public class CustomSendEmail : WffmSaveAction
public override void Execute(ID formId, AdaptedResultList adaptedFields,
ActionCallContext actionCallContext = null, params object data)
var sitecoreService = new SitecoreService(Context.Database);
var adaptedDriverField = FindCustomEmailDropListField(adaptedFields);
if (adaptedDriverField == null)
// Log the warning if this save action is applied without using custom field
“Warning: Custom Send Email Custom action will not work without Custom Email Drop List field, please make sure you have this type of field (Field Type ID =add the field id for ease) in WFFM Form: ” +
//Get the ID for the selected item
var adaptedFieldValue = ID.Parse(adaptedDriverField.Value);
// Get the Item from sitecore based on selected ID
var emailItem = Context.Database.GetItem(adaptedFieldValue);
if (emailItem != null)
// emailItem will have field for email action such as to, cc, bcc, subject etc. this method will use these field as well as the smtp information on the action to send the email
EmailUtility.SendCustomEmail(this, emailItem, adaptedFields);
catch (Exception ex)
Log.Error(“Error: Custom Send Email Custom action is not working for WFFM Form: ” + formId, ex, this);
private AdaptedControlResult FindCustomEmailDropListField(AdaptedResultList adaptedFields)
AdaptedControlResult driverField = null;
foreach (AdaptedControlResult adpatedControlResult in adaptedFields)
var fieldItem = Context.Database.GetItem(adpatedControlResult.FieldID);
// get the custom duplicate dropdown field
if (fieldItem.Fields[“Field Link”].Value != “ID of the Field”) continue;
driverField = adpatedControlResult;