我在使用 SMTP/.NET 邮件将内联 HTML 发送到电子邮件时遇到问题。我已经尝试过标准类以及 MailDefininition 类,但我不断地内联原始代码,而不是翻译的页面。
我知道这可能是我缺少的一些小东西,下面是我的代码。谢谢
public static void SendMail(string toAddress, string subject, string messageBody)
{
MailDefinition message = new MailDefinition();
message.CC = MailCCAddress;
message.From = "orders@test.com";
message.Subject = subject;
message.IsBodyHtml = true;
ListDictionary replacements = new ListDictionary();
System.Net.Mail.MailMessage fileMsg;
fileMsg = message.CreateMailMessage(toAddress, replacements, messageBody, new System.Web.UI.Control());
string _hostName = HostName;
SmtpClient client = new SmtpClient(_hostName);
client.Credentials = CredentialCache.DefaultNetworkCredentials;
//client.Send(message);
client.Send(fileMsg);
}