Copied to clipboard

Flag this post as spam?

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


  • Jeff Lewis 14 posts 84 karma points
    Sep 11, 2017 @ 18:32
    Jeff Lewis
    0

    Conditional Recipient?

    Greetings.

    I love this package, it definitely makes it easy to create and send emails for content managers.

    I have a question though - is there any way to conditionally set the recipient of an email coming from an Umbraco Form given another value from the form? Say, change the email address being sent to based on a department chosen in a dropdown in the form?

    I am using the code below in my 'To' property in my 'Contact Us' email, for example, and it does not work. If I hard code the email address, it sends the email fine, and includes values from the Umbraco form, including the value of [#property#] that I'm trying to use in the conditional statement.

    Also, if I include the code in the 'Body' property of the email content, the correct email address is displayed in the email.

    {if [#property#] = 'Some Value' } [email protected] {else} [email protected] {/if}
    

    I get the following error in my logs:

    2017-09-11 13:22:06,372 [P5048/D11/T298] ERROR Umbraco.Forms.Core.Services.WorkflowService - Form workflow 'Send Contact Email' failed on 'Submitted' of Record with Unique ID 'ca19e916-8965-47b4-ab06-24175b074bac' from the Form named 'Contact Us' with Unique ID '16fd698d-36b6-4847-a821-4b159a807d21'
    System.Exception: Could not determine the primary recipient for the email. Please specify a 'to', 'cc' or 'bcc' recipient.
       at PerplexMail.Email.SendEmail()
       at PerplexMail.UmbracoForms.EmailWorkflow.Execute(Record record, RecordEventArgs e)
       at Umbraco.Forms.Core.Services.WorkflowService.ExecuteWorkflows(List`1 workflows, RecordEventArgs e)
    

    Thanks,

    jeff

  • [email protected] 406 posts 2135 karma points MVP 7x c-trib
    Sep 13, 2017 @ 13:33
    jeffrey@umarketingsuite.com
    0

    Hi Jeff,

    thanks for using our package, and I didn't ever used the functionality in the way you've described it. But I do think this should work, because if we look at the sourcecode, first the if-then-else-parsing and tag-parsing is done before handing it over to emailservice.

    You could for testing purposes do two things:

    1) Set your own emailadres in the cc so you won't get the error and the mail get sent and look if there's a 'to' specified according to your tag

    2) You could strip out the spaces in the if-then-else because I don't know whether they make the emailadress invalid

    Last option is to try to fix it yourself in the sourcecode that is available on Github (https://github.com/PerplexInternetmarketing/PerplexMail-for-Umbraco).

    Hope you can make it work; keep me posted!

    Jeffrey

  • John Logan 24 posts 65 karma points
    Oct 17, 2017 @ 12:22
    John Logan
    0

    Hi Jeff

    Did you get this to work? I was after something similar

    Cheers J

  • Jeff Lewis 14 posts 84 karma points
    Oct 17, 2017 @ 18:52
    Jeff Lewis
    0

    Hey John,

    Unfortunately I did not. I had previously tried removing all spaces, but it didn't work. Regardless, I needed multiple conditions, and the PerplexMail if-then-else logic does not support multiple conditions, so I went a different route.

    jeff

Please Sign in or register to post replies

Write your reply to:

Draft