1

I'm working on an upgrade from Sitecore 7.5 (rev. 141003) to 8.2 u2. There is a custom save action in the old project that ends up appending some data about the user currently filling out the form. The issue I'm running into is with attaching files. The function IncludeAttachments is not in Sitecore.WFFM.Actions.SaveActions.SendMessage so I'm not too sure how I can replicate that. Is overriding the entire email functionality for wffm really necessary or is there some kind of pipeline/property in the SendMessage class I can override to append this user data to instead of overriding the Execute action? If not I think I'm going to need to manually attach the files by duplicating the functionality that was in the IncludeAttachments method and looping through the fields being passed into my class's Execute method which sounds kind of brutal.

  • I would have a look at this post. jonathanrobbins.co.uk/2015/02/18/… Do you have a custom field type for your form? – Charles Afford Apr 9 '17 at 17:41
  • 1
    I've been looking at ensuring attachments are added to emails myself and it seems from this it is possible to use the <IsIncludeAttachments></IsIncludeAttachments> config in the settings for the save action in wffm (see link below). I was trying to do some local testing of this to verify but I've not had chance to get it working yet. I think you will certainly still need a custom save action for your custom user data though. doc.sitecore.net/web_forms_for_marketers/… – Adam Seabridge Apr 10 '17 at 13:29
  • @CharlesAfford I'll check it out and post my code if I get something coherent working. Running the pipeline seems like the way to go although it seems like some part of that post are a bit off/there are dependencies missing. – Teeknow Apr 10 '17 at 19:53
0
using Sitecore.Data;
using Sitecore.WFFM.Abstractions.Actions;
using Sitecore.WFFM.Abstractions.Shared;

namespace Sample.Namespace
{
    public class SendMessage : global::Sitecore.WFFM.Actions.SaveActions.SendMessage
    {
        public SendMessage(ISettings settings, IMailSender mailSender) : base(settings, mailSender)
        {
        }

        public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data)
        {
            var dataToAppend = "Get user profile data here... I had a custom extension method"
            //Note that Mail is a property inherited from the base class
            //There are many other properties with setters that allow 
            //customization of other things if necessary which can be
            //seen with the IsBodyHtml and IsIncludeAttachments properties
            Mail = $@"{dataToAppend}{Mail}";

            IsBodyHtml = true;
            IsIncludeAttachments = true;

            base.Execute(formId, adaptedFields, actionCallContext, data);
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.