asp.net怎么用html模板发送邮件。希望可以有源码。
发布网友
发布时间:2022-04-28 22:34
我来回答
共1个回答
热心网友
时间:2022-04-20 11:25
private string username = “”/mail的用户账号
private string password = “”;//mail的用户账号的密码
private string Host = "mail.xinlang.net"; 邮件服务地址
public int SendSMTPEMail(string strto, string strSubject, string strBody)
{
int err = 0;
try
{
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(Host);
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential(username, password);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
System.Net.Mail.MailMessage message = new MailMessage(username, strto, strSubject, strBody);
message.BodyEncoding = encoding;
message.IsBodyHtml = true; // 允许邮件主体使用HTML
client.Send(message);
err = 1;
}
catch (Exception ex)
{
err = 0;
}
return err;
}
我用过的