如何使用asp.net C#发送带有内容html标签的邮件? [英] How to send mail with content html tag using asp.net C# ?

查看:316
本文介绍了如何使用asp.net C#发送带有内容html标签的邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以帮助我使函数使用asp.net C#发送带有内容html标签的邮件吗?

Can help me make function send mail with content html tag using asp.net C# ?

推荐答案

单击此处: ^ ] ]的HTML邮件
Click there: html mail in c#[^]


只是一个提示:电子邮件应具有"Content-Type:text/html";例如,您可以使用标题行之一
Just a hint: the e-mail should have "Content-Type: text/html"; for example, you can have one of the header lines
Content-Type: text/html; charset="utf-8"



—SA



—SA


您可以使用此库发送邮件.
http://higlabo.codeplex.com/ [ ^ ]

You can send mail with this library.
http://higlabo.codeplex.com/[^]

SmtpClient cl = new SmtpClient();
cl.ServerName = "your server name";
cl.Port = 25;
cl.Ssl = false;
SmtpMessage mg = new SmtpMessage();
mg.Subject = "Html mail test";
mg.From = "my_address@mail.com";
mg.To.Add(new MailAddress("address@mail.com"));
//Send by HTML format
SmtpContent ct = new SmtpContent();
ct.LoadHtml("<html><head></head><body>......</body></html>");
mg.Contents.Add(ct);

var rs = cl.SendMail(mg);
//Check mail was sent or not
if (rs.SendSuccessfull == false)
{
    //You can get information about send mail is success or error reason
    var resultState = rs.State;
}


这篇关于如何使用asp.net C#发送带有内容html标签的邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆