How to call the CMS Email Template in C# Code

Ram G asked on July 22, 2019 14:59

I created one Email template in Kentico 10. 1. How to use the Email template in c#code. 2. I created the one kentico cms form, once submit the form after I need to show the success message in popup window. how to do?

Recent Answers


Roman Hutnyk answered on July 22, 2019 15:07

Can't find appropriate link, so I'll drop code sample here:

EmailMessage msg = new EmailMessage();
            EmailTemplateInfo eti = EmailTemplateProvider.GetEmailTemplate("ReviewRequest", SiteContext.CurrentSiteID);

                        MacroResolver mcr = MacroResolver.GetInstance();

            mcr.SetNamedSourceData("url", reviewPageUrl);
            mcr.SetNamedSourceData("training", training);

            msg.EmailFormat = EmailFormatEnum.Html;
            msg.From = eti.TemplateFrom;
            msg.BccRecipients = eti.TemplateBcc;
            msg.Recipients = user.Email;
            msg.Subject = eti.TemplateSubject;

            EmailSender.SendEmailWithTemplateText(SiteContext.CurrentSiteName, msg, eti, mcr, true);
0 votesVote for this answer Mark as a Correct answer

Ram G answered on July 22, 2019 17:01

I am not understand

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on July 22, 2019 17:29

That was the answer for the first question.

Kentico offers you a mechanism to show up thank you message without popup. If popup is absolute requirement - use javascript.

0 votesVote for this answer Mark as a Correct answer

Ram G answered on July 22, 2019 17:53 (last edited on July 25, 2019 10:13)

Yes It is absolute requirements.

Below is the Layout code:

0 votesVote for this answer Mark as a Correct answer

Ram G answered on July 22, 2019 17:54

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on July 23, 2019 15:09

  1. Setup your form to show thank you message with out of the box functionality
  2. implement javascript that check on page load if thank you message is present on the page and if so - show popup with javascript
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.