Copied to clipboard

Flag this post as spam?

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


  • Damon 217 posts 287 karma points
    Dec 14, 2015 @ 10:34
    Damon
    0

    Umbraco Forms - how to dynamically send to selected email address?

    Hi,

    I am building some Umbraco Forms. Instead of having the form send to email addresses added in the back office, we want to send the forms information to an address that is selected by the user from a drop down menu containing multiple email addresses.

    How can this be achieved?

    Thanks a lot for any info!

  • Paul 10 posts 102 karma points
    Dec 14, 2015 @ 15:57
    Paul
    0

    Hi Damon,

    You should be able to use the bracket syntax to access the form values from the email workflow settings.

    So for your example you might have a drop down field called Address to Send To which contains all the valid email address's. To access the value that has been selected by the user you would use {addresstosendto} in the email receiver field found in the work flow settings.

    Hopefully this is what you are looking for.

    Paul

  • Damon 217 posts 287 karma points
    Dec 15, 2015 @ 10:18
    Damon
    0

    Hi Paul,

    thanks that is good. One other thing though. I want to be able to list names in the dropdown menu and then associate those names with actual email addresses. Do you know how this can be achieved?

    Thanks a lot!

  • qrayg 24 posts 92 karma points
    Feb 24, 2016 @ 15:51
    qrayg
    0

    I ended up using jQuery to solve this because I can't find any other decent way. All the tutorials out there are for a very old version of Contour and the new Umbraco Forms does not have the same options. Here was my solution:

    <script>
    $(document).ready(function(){
      $('option[value^="sales@"]').html('Sales');
      $('option[value^="service@"]').html('Service');
      ...
    });
    </script>
    

    I placed this code block on the page with the embedded form and it renders the way I want.

    It would be more idea if Umbraco Forms select boxes supported both field values as well as a way to edit/move the values after they have been created.

  • rasshme 9 posts 80 karma points
    Apr 26, 2017 @ 07:38
    rasshme
    0

    you can create a custom dropdown like below. Add this to your form and set the comma separated values . enter each email, text pair in new line. Then you can capture the selected value (email address) in your custom workflow and send email accordingly.

    public sealed class EnhancedDropDownList : FieldType
            {
                [global::Umbraco.Forms.Core.Attributes.Setting("Comma-separated values. The first value is the value that will be submitted. The second value is the display name.", view = "textarea", description = "The first value is the value that will be submitted. The second value is the display name.")]
                public string PreValues { get; set; }
    
                [global::Umbraco.Forms.Core.Attributes.Setting("Default Value", view = "textfield", description = "Default value of the dropdownlist")]
                public string DefaultValue { get; set; }
    
                public EnhancedDropDownList()
                {
                    Name = "Enhanced Drop Down List";
                    Id = new Guid("10942e58-4e0f-4e5c-8371-14e32ca2c571");
                    Description = "DropDownList with extra features";
                    Icon = "dropdownlist.png";
                    DataType = FieldDataType.String;                
                }
    
                public string RenderPreview()
                {
                    return "<select><option value=\"\"></option></select>";
                }
    
                public string RenderPreviewWithPrevalues(List<object> prevalues)
                {
                    return RenderPreview();
                }            
            }
    
Please Sign in or register to post replies

Write your reply to:

Draft