Friday, October 21, 2016

Sitecore WFFM 8.1 : Setup Custom Send Email Message



Step1 : Create a CustomSendEmail class as below:

    public class CustomSendEmail: SendMessage
    {
        public SendEmailTest(ISettings settings, IMailSender mailSender) : base(settings, mailSender)
    {

        }
        public override void Execute(ID formId, AdaptedResultList adaptedFields,ActionCallContext actionCallContext = null, params object[] data)                data)
        {
            Sitecore.Diagnostics.Log.Info("enter the test execute", this);
            base.Execute(formId, adaptedFields, actionCallContext, data);
        }
    }


Step 2: Update "Sitecore.WFFM.Dependencies.config" in App_config/Include folder,


<CustomSendEmail type="MyCustomNamespace.CustomSendEmail, MyAssembly">
          <param name="settings" ref="/sitecore/wffm/settings" />
          <param name="mailSender" ref="/sitecore/wffm/mailSender" />
</CustomSendEmail>



<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <wffm>
...
      <!--Save actions constructor configuration-->
      <actions>
...
        <sendMessage type="Sitecore.WFFM.Actions.SaveActions.SendMessage, Sitecore.WFFM.Actions">
          <param name="settings" ref="/sitecore/wffm/settings" />
          <param name="mailSender" ref="/sitecore/wffm/mailSender" />
        </sendMessage>
...
      </actions>
...
    </wffm>
  </sitecore>
</configuration>


Step 3:

After that create a duplicate item /sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions/Send Email Message,
renamed it into CustomSend Mail and changed the Factory Object name into the following:

/sitecore/wffm/actions/CustomSendEmail


Happy coding!

2 comments: