条件に基づいて電子メールを生成する必要があります。ここでは、電子メールのテンプレートは次のとおりです。kentico8の電子メールテンプレートでif-elseステートメントでHTMLタグがレンダリングされない
<html>
<head>
</head>
<body style="font-size: 12px; font-family: arial">
<p>
This is an automatic notification sent by Kentico. The following document is waiting for your approval. Please sign in to the Kentico administration interface and approve it.
</p><br />
{%if (2<3) { %}
<p>
<b><i>This is Sent By : {%SentBy%}</i></b><br /><br />
<a href={%siteurl%}>SiteURL</a><br />
<br />
</p>
{% }else{%}
<p>This is else Method</p>
{%}#%}
</body>
</html>
そしてここでの背後にあるコードは次のとおりです。
EmailMessage msg = new CMS.EmailEngine.EmailMessage();
EmailTemplateInfo etInfo = EmailTemplateProvider.GetEmailTemplate("Email", SiteContext.CurrentSiteID);
if (etInfo != null)
{
MacroResolver mcr = MacroResolver.GetInstance();
mcr.SetNamedSourceData("siteurl", "http://google.com/");
mcr.SetNamedSourceData("SentBy", "admin");
msg.EmailFormat = EmailFormatEnum.Both;
msg.From = etInfo.TemplateFrom;
msg.Recipients = "[email protected]";
msg.Subject = etInfo.TemplateSubject;
msg.Body = etInfo.TemplateText;
msg.PlainTextBody = etInfo.TemplatePlainText;
//Send Email..
EmailSender.SendEmailWithTemplateText(SiteContext.CurrentSiteName, msg, etInfo, mcr, true);
}
私は次のようにそれがレンダリングされる電子メールを送信する場合:
This is an automatic notification sent by Kentico. The following document is waiting for your approval. Please sign in to the Kentico administration interface and approve it.
<p> <b><i>This is Sent By : admin</i></b><br /><br /> <a href=http://google.com/>SiteURL</a><br /> <br /> </p>
すべてのHTML if条件の下にあるタグは表示されません。
ありがとうございます。正常に動作します。 – sadasiva
それを聞いてうれしい。その場合、あなたは答えを受け入れることができます:) – Enn