0
Emailservicerequest.Email = new Email();
            Emailservicerequest.Email.FromEmail = Insertcampaignrequest.Campaign.SenderAddress;
            Emailservicerequest.Email.ToEmail = Insertcampaignrequest.Campaign.RecipientsFilter;
            Emailservicerequest.Email.Subject = Insertcampaignrequest.Campaign.Subject;

           // Emailservicerequest.Email = true;

            Emailservicerequest.Email.Body = Convert.ToString(MailFormat.Html);
            Emailservicerequest.Email.Body = "Provider/EmailTemplate/email.html";
 Emailserviceresponse=Emailservice.SendEmail(Emailservicerequest);
4

2 回答 2

0

在 Asp.net 4.0 中,您应该使用 T4 模板来创建电子邮件模板。它简单且易于管理。

更多信息 http://asmiki.com/2011/05/20/using-t4-templates-for-compiling-net-email-templates/

问候

于 2012-04-27T05:48:17.173 回答
0

要将您的 HTML 文件转换为字符串,以便您可以将其设置为电子邮件对象的正文值,您可以使用以下函数:

public string ReturnHTML(string Path)
     {
         string strBody = "";
         try
            {
                StreamReader objReader = new StreamReader(Path);
                strBody = objReader.ReadToEnd();
                objReader.Close();
            }
         catch (Exception ex)
            {
                strBody = "";
                throw ex;
            }
            return strBody;
     }

在您的代码中调用上述函数

string path = Server.MapPath(ConfigurationManager.AppSettings["NoticeApprovalPath"].ToString());
string tempStr = cmm.ReturnHTML(path);
tempStr = tempStr.Replace("[xxxNoticeIDxxx]", Convert.ToString(RequestID));

replace 函数用于替换 HTML 模板中的值:

这里[xxxNoticeIDxxx]是替换为RequestID包含数据的值变量。

于 2012-04-27T05:50:55.493 回答