Skip to main content

Customize the Send Email Message save action

Abstract

How to configure an email message using the ProcessMessage pipeline.

The Send Email Message save action sends an e-mail message every time a visitor clicks the Submit button on a web form. You can configure an email message in this save action using the ProcessMessage pipeline.

To configure an email message:

  1. Create a processor class using the following sample code:

    using Sitecore.Form.Core.Pipelines.ProcessMessage;
    // This processor adds a note to the end of the email body
      public class AddTextToBody
      {
        public void Process(ProcessMessageArgs args)
        {
          string additionalText = "<p>This message was sent using the Sitecore Web Forms for Marketers module.</p>";
          args.Mail.Append(additionalText);
          /*
           * it's also possible to modify SUBJECT, TO, CC and BCC message fields
           * args.Subject.Append(" subject text");
           * args.To.Append("; secondrecipient@mail.net");
           * args.CC.Append("; secondrecipient@mail.net");
           * args.BCC.Append("; secondrecipient@mail.net");
           * args.From = "sender@mail.net";
           */
        }
      }
    
  2. Register the new processor in the Sitecore.Forms.config file, before the Sitecore.Form.Core.Pipelines.ProcessMessage.ProcessMessage processor:

          <processMessage>        
            …
            <processor type="YourNamespace.AddTextToBody,YourAssemblyName" />
            <processor type="Sitecore.Form.Core.Pipelines.ProcessMessage.ProcessMessage, Sitecore.Forms.Core" method="SendEmail"/>
          </processMessage>