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 11 posts 81 karma points
    1 week ago
    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' } some@email.com {else} other@email.com {/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

  • jeffrey.schoemaker@perplex.nl 216 posts 776 karma points mvp c-trib
    1 week ago
    jeffrey.schoemaker@perplex.nl
    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

Please Sign in or register to post replies

Write your reply to:

Draft