在 C# 中生成 HTML 电子邮件(通过 System.Net.Mail 发送)是否有比使用 Stringbuilder 执行以下操作更好的方法:
string userName = "John Doe";
StringBuilder mailBody = new StringBuilder();
mailBody.AppendFormat("<h1>Heading Here</h1>");
mailBody.AppendFormat("Dear {0}," userName);
mailBody.AppendFormat("<br />");
mailBody.AppendFormat("<p>First part of the email body goes here</p>");
等等等等?
原文由 Rob 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以使用 MailDefinition 类。
这是你如何使用它:
此外,我还写了一篇关于如何 使用 MailDefinition 类使用模板在 C# 中生成 HTML 电子邮件正文的博文。