Copied to clipboard

Flag this post as spam?

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


  • M 40 posts 273 karma points
    May 23, 2019 @ 11:03
    M
    0

    Custom workflow using email template

    I've created a custom workflow to allow me to CC form submissions to an email address using https://our.umbraco.com/forum/umbraco-forms/87822-how-to-add-reply-to-bcc-functionality-to-umbraco-forms as a basis.

    I'd now like to include the "razor email template functionality" of the default workflow. I've added

    [Umbraco.Forms.Core.Attributes.Setting("Email Template", description = "Email template to use", view = "EmailTemplatePicker")]
        public string EmailTemplate { get; set; }
    

    So I've got a picker working now, but I'm not sure how to combine the form submission with the template.

    I've seen this on the forums, but it seems a bit long winded for something that's already built in somewhere.

    Can anybody point me in the right direction?

  • M 40 posts 273 karma points
    Jun 17, 2019 @ 13:26
    M
    101

    Turns out there is an easier way. Within your custom workflow's execute method you can do

    record.ParseWithRazorView(filePath);
    

    Easy when you know how.

  • Rick 31 posts 81 karma points
    Dec 15, 2020 @ 17:31
    Rick
    0

    How did you get this working? When I add:

    record.ParseWithRazorView(filePath);
    

    I get "'Record does not contain a definition for 'ParseWithRazorView'", and I don't get any suggestions for using namespaces...

  • M 40 posts 273 karma points
    Dec 16, 2020 @ 08:58
    M
    0

    I don't remember doing anything special - my code and namespaces are broadly similar to the link in the first post. Here's the relevant extract, if that helps:

    public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
        {
            MailMessage m = new MailMessage();
            m.From = new MailAddress(Properties.Settings.Default.emailFrom);
            m.Subject = Subject;
            m.IsBodyHtml = true;
    
            var bodyFromView = record.ParseWithRazorView("~/Views/Partials/" + EmailTemplate);
    
    m.Body = bodyFromView ;
            SmtpClient s = new SmtpClient(Properties.Settings.Default.smtpServer);
            s.Send(m);
            return WorkflowExecutionStatus.Completed;
        }
    
  • Rick 31 posts 81 karma points
    Dec 16, 2020 @ 10:40
    Rick
    0

    Ok, thanks. But for some reason this doesn't work for me.

    When I use that exact code I still get "CS1061: 'Record' does not contain a definition for 'ParseWithRazorView' and no accessible extension method 'ParseWithRazorView' accepting a first argument of type 'Record' could be found (are you missing a using directive or an assembly reference?"

    Btw, I'm using Umbraco Forms version 8.6.0

    I've got it working now with a plain .html-file as a workaround, but would be nice if I can use the Picker-functionality from Forms itself. Maybe someone else reads this and got the solution :-)

  • M 40 posts 273 karma points
    Dec 16, 2020 @ 11:02
    M
    0

    Ah I'm using v7 forms, so that could be it.

  • Manish Manandhar 5 posts 74 karma points
    Aug 03, 2022 @ 01:38
    Manish Manandhar
    0

    Hey Rick,

    Any update on this one? Also can you please elaborate on the workaround for this one?

    Thanks :)

  • Rick 31 posts 81 karma points
    Aug 03, 2022 @ 15:01
    Rick
    0

    Sorry, but I actually have no idea anymore which project this was... So can't look it up for you... Sorry :)

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Feb 03, 2021 @ 22:52
    Alex Skrypnyk
    1

    this is working for v8:

    var sendEmailWorkflow = new Umbraco.Forms.Core.Providers.WorkflowTypes.SendEmail(_xmlService, _contentSection)
    {
        Email = email,
        SenderEmail = SenderEmail,
        Subject = Subject,
        Message = Message,
        Attachment = Attachment
    };
    sendEmailWorkflow.Execute(record, e);
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies