text 发送电子邮件模板
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 发送电子邮件模板相关的知识,希望对你有一定的参考价值。
protected bool SendEmail()
{
try
{
var emailTemplateInfo = EmailTemplateProvider.GetEmailTemplate("ECO_NewsletterSignup", SiteContext.CurrentSiteID);
if (emailTemplateInfo == null)
return false;
var emailAddress = StringHelper.TruncateString(txtEmailAddress.Text.Trim(), EmailAddressMaxLength);
var firstName = StringHelper.TruncateString(txtFirstName.Text.Trim(), FirstNameMaxLength);
if (String.IsNullOrWhiteSpace(emailAddress) || String.IsNullOrWhiteSpace(firstName))
{
EventLogProvider.LogEvent(EventType.ERROR, EventLogSource, "Error", "Required field(s) are missing");
return false;
}
var emailMessage = new EmailMessage();
var macroResolver = MacroResolver.GetInstance();
macroResolver.SetNamedSourceData("EmailAddress", emailAddress);
macroResolver.SetNamedSourceData("FirstName", firstName);
emailMessage.EmailFormat = EmailFormatEnum.Html;
emailMessage.From = emailTemplateInfo.TemplateFrom;
emailMessage.Recipients = emailAddress;
emailMessage.Subject = emailTemplateInfo.TemplateSubject;
EmailSender.SendEmailWithTemplateText(SiteContext.CurrentSiteName, emailMessage, emailTemplateInfo, macroResolver, false);
return true;
}
catch (Exception ex)
{
EventLogProvider.LogException("EmailHelper", "Send", ex);
return false;
}
}
以上是关于text 发送电子邮件模板的主要内容,如果未能解决你的问题,请参考以下文章
根据xlsx模板生成excel数据文件发送邮件代码
使用邮件模板(freemarker.jar)发送邮件
shell发送网页邮件
Django 多模板继承
text 电子邮件模板所有电子邮件模板编辑电
邮戳:发送带有模板的电子邮件