Custom Emails for Webform 7.x-3.x

Custom Emails for Webform 7.x-3.x afrank30
Drupal Version
Tags

The following instructions show how to make it easier to read Webform data sent in emails (for Webform 7.x-3.x).

Under the Emails tab for a Webform, find the section titled Email template.

Default template

If you choose "Default template" from the drop down box, you usually have this code:

Submitted on %date
Submitted by user: %username
Submitted values are:
%email_values

The results of this submission may be viewed at:
%submission_url

Custom template

However, if you choose "Custom template" from the drop down box, you can customize how your webform data is output in the email(s) that are sent. For example, unless people are creating accounts on your site, you may want to remove the %username line.

Key values

Of more frequent use, though, is the need to simplify submitted data and shorten the labels. To include and format a specific piece of data in this email, use %value[key], where key is the machine name of the field holding that data.

Keys can be found under the Form components tab for a webform. For each field you want to include in the email, select Edit"for that field's row, and copy the Field Key.

Example template

An example custom email template, where you let webform create the names of your field Keys, based on the Label you gave each field, might look like this:

Submitted on %date

DETAILS:

Contact Person:
%value[contact_person]
%value[email]
Work: %value[work_phone]
Cell: %value[cell_phone_if_applicable]

Event Details:
Name: %value[event_name]
Date: %value[event_date] from %value[event_start_time] to %value[event_end_time]
Location: %value[event_location_please_include_rain_location_if_applicable]

The results of this submission may be viewed at:

%submission_url