Copied to clipboard

Flag this post as spam?

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


  • David Zweben 265 posts 749 karma points
    Jul 19, 2018 @ 17:17
    David Zweben
    0

    Sending out template emails programmatically?

    I am setting up a membership section on our website, and I need it to send an account confirmation email. Rather than hard-coding the format of the email, I'd like to use a CSHTML template, like the ones Umbraco Forms uses. I see packages that enable this, but for our project we're trying to avoid 3rd-party packages.

    Is there any way to do one of the following?

    • From a Surface Controller, programmatically post data (email address and email confirmation link) to an Umbraco Forms form, and trigger a template-based Workflow email to be sent to the email that was passed programmatically.

    • From a Surface Controller, trigger the code that Umbraco Forms uses to send out template-based emails, pass data into that email template, and send out an email (not necessarily sending data into Umbraco Forms).

    Any other thoughts on how I could send out a template-based email without a 3rd-party package would be greatly appreciated.

    Thanks,
    David

  • Nigel Wilson 944 posts 2076 karma points
    Jul 20, 2018 @ 00:34
    Nigel Wilson
    100

    Hi David

    The following is all theory but might get you started...

    In the controller you would need to "scrape" the rendered html from the page to form the email content.

    So with this in mind:

    1. Setup the template you want
    2. Test is renders OK in the browser.
    3. In order to personalise you would obviously need to use the member ID, so could code the page so that it can read a query string parameter via a controller, and render the page based on the resulting model.
    4. Then in your email controller code up the URL and read the resulting HTML from it.
    5. Embed as the body content in your email

    Hope this helps

    Nigel

  • David Zweben 265 posts 749 karma points
    Jul 27, 2018 @ 12:12
    David Zweben
    0

    Nigel,

    Great idea, I'm going to use this approach.

    Thanks,
    David

Please Sign in or register to post replies

Write your reply to:

Draft