Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan Evans 629 posts 1016 karma points
    Feb 05, 2016 @ 09:43
    Dan Evans
    0

    Default work flow email template.

    Is it possible to edit the default email template used to send messages in workflow? Where would I find it?

    Thanks

    Dan

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Feb 05, 2016 @ 10:29
    Dennis Aaen
    0

    Hi Dan,

    What you can do to be able to customize the email, is to use the Send xslt transformed email workflow. With this you have full control over the email contents by supplying an xslt file.

    If you can let me know if you are using Contour or Umbraco Forms, then I can guide you a bit more.

    /Dennis

  • Dan Evans 629 posts 1016 karma points
    Feb 05, 2016 @ 10:41
    Dan Evans
    0

    Umbraco forms I've done this in Contour so guidance and a sample file would be great. Thanks

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Feb 05, 2016 @ 12:36
    Dennis Aaen
    0

    Hi Dan,

    You can find the example file here \App_Plugins\UmbracoForms\Xslt\sendXsltEmailSample.xslt.

    Take a copy of this file, and uploaded in the media library, then you can attach it on the workflow for your form.

    https://our.umbraco.org/documentation/Add-ons/UmbracoForms/Editor/Attaching-Workflows/

    Hope this helps,

    /Dennis

  • Dan Evans 629 posts 1016 karma points
    Feb 09, 2016 @ 14:44
    Dan Evans
    0

    Hi Dennis

    This is great but it's not quite what I need. When using the standard send email there is a message field for users to complete a message to the user. We can then use the {bracket} syntax to add in the particular form fields we want to include in the email. So all we really want to do is remove the data dump at the end of this email.

    Alternatively, using the XSLT as you recommend, how would I add in a custom message from the user and use the {bracket} syntax? There is no message box when this option is selected.

    Thanks

    Dan

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Feb 09, 2016 @ 14:56
    Dennis Aaen
    0

    Hi Dan,

    If you choose to use the XSLT approach you donĀ“t have the thank you message field. You should be able to use the {bracket} syntax to add in the particular form fields in the thank you message field.

    If this not work for you then you can submit a feature request here. http://issues.umbraco.org/issues/CON

    /Dennis

  • Joshua Stewart 36 posts 128 karma points c-trib
    Feb 09, 2016 @ 15:02
    Joshua Stewart
    0

    Hi Dan,

    Here is a link that might help - it's a gist of the Send Email Workflow.

    https://gist.github.com/TimGeyssens/3fffc0a4a6e457a0cd08

    Also, workflows are coded the same Contour and Umbraco Forms - so any code for one should work for the other.

    You should be able to modify the code above to create a new workflow to do what you need.

  • Dan Evans 629 posts 1016 karma points
    Feb 09, 2016 @ 15:35
    Dan Evans
    0

    Dennis - I have added this as a feature request.

    Joshua - that's what I needed though this is the latest version for Umbraco Forms here - https://gist.github.com/TimGeyssens/6ff5392c4d9bbf89bdfc

    Here is the amended workflow - just drop it in App_Code or compile as a dll.

     using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Umbraco.Forms.Core.Enums;
    using System.Text.RegularExpressions;
    using Umbraco.Forms.Data.Storage;
    using System.Xml;
    using System.Xml.XPath;
    using System.Web;
    using System.Net.Mail;
    
    
    namespace Umbraco.Forms.Core.Providers.WorkflowTypes
    {
        public class SendEmailNoData : WorkflowType
        {
            [Attributes.Setting("Email", description = "Enter the receiver email", view = "TextField")]
            public string Email { get; set; }
    
            [Attributes.Setting("SenderEmail", description = "Enter the sender email (if blank it will use the settings from /config/umbracosettings.config)", view = "TextField")]
            public string SenderEmail { get; set; }
    
            [Attributes.Setting("Subject", description = "Enter the subject", view = "TextField")]
            public string Subject { get; set; }
    
            [Attributes.Setting("Message", description = "Enter the intro message", view = "TextArea")]
            public string Message { get; set; }
    
            [Attributes.Setting("Attachment", description = "Attach file uploads to email", view = "Checkbox")]
            public string Attachment { get; set; }
    
            public SendEmailNoData()
            {
                this.Id = new Guid("32ee1bc2-afcd-4bab-a3af-a28ca97bef85");
                this.Name = "Send email without form data";
                this.Description = "Send the result of the form to an email address";
            }
    
            public override List<Exception> ValidateSettings()
            {
                List<Exception> l = new List<Exception>();
                if (string.IsNullOrEmpty(Email))
                    l.Add(new Exception("'Email' setting has not been set"));
    
                if (string.IsNullOrEmpty(Message))
                    l.Add(new Exception("'Message' setting has not been set'"));
    
    
                return l;
            }
    
            public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
            {
    
    
                System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage();
                m.From = new System.Net.Mail.MailAddress(string.IsNullOrEmpty(SenderEmail) ? umbraco.UmbracoSettings.NotificationEmailSender : SenderEmail);
                m.Subject = Subject;
                m.IsBodyHtml = true;
    
                if (Email.Contains(';'))
                {
                    string[] emails = Email.Split(';');
                    foreach (string email in emails)
                    {
                        m.To.Add(email.Trim());
                    }
                }
                else
                {
                    m.To.Add(Email);
                }
    
                //RecordsViewer viewer = new RecordsViewer();
                XmlNode xml = record.ToXml(new System.Xml.XmlDocument()); //viewer.GetSingleXmlRecord(record, new System.Xml.XmlDocument());
    
    
    
                XPathNavigator navigator = xml.CreateNavigator();
    
                XPathExpression selectExpression = navigator.Compile("//fields/child::*");
                selectExpression.AddSort("@pageindex", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Number);
                selectExpression.AddSort("@fieldsetindex", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Number);
                selectExpression.AddSort("@sortorder", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Number);
    
                XPathNodeIterator nodeIterator = navigator.Select(selectExpression);
    
                string list = "<dl>";
                while (nodeIterator.MoveNext())
                {
                    list += "<dt><strong>" +
                            Umbraco.Forms.Data.DictionaryHelper.GetText(
                                nodeIterator.Current.SelectSingleNode("caption").Value) + ": </strong><dt><dd>";
    
                    XPathNodeIterator values = nodeIterator.Current.Select(".//value");
    
                    while (values.MoveNext())
                    {
                        var val = values.Current.Value.Trim();
                        list +=
                            Umbraco.Forms.Data.DictionaryHelper.GetText(val)
                                .Replace("\n", "<br/>") + "<br/>";
    
                        if (this.Attachment == true.ToString() &&
                            val.Contains("/forms/upload"))
                        {
                            // add attachment
                            string filelocation = HttpContext.Current.Server.MapPath(val);
                            m.Attachments.Add(new Attachment(filelocation));
                        }
                    }
                    list += "</dd>";
    
                }
    
                list += "</dl>";
    
                m.Body = "<p>" + Message.Replace("\n", "<br/>") + "</p>";// + list;
    
                System.Net.Mail.SmtpClient s = new System.Net.Mail.SmtpClient();
    
                s.Send(m);
    
                return WorkflowExecutionStatus.Completed;
            }
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft