/*
豆腐制作,都是精品
http://www.asp888.net 豆腐技术站
如转载 请注明出处
*/
asp+发送Email 完全手册,本文包含我们发送Mail的所有常见的例子,当然,限于篇幅,我们只是
简单的举例子,如果大家有什么意见的话,欢迎到 http://www.asp888.net/bbs 讨论
1.用asp+发送简单的Mail
1 @Page Language="C#"
1 @Import Namespace="System.Web.Util"
1
2string strTo = "[email protected]";
3string strFrom = "[email protected]";
4string strSubject = "asp发送mail简单例子";
5
6SmtpMail.Send(strFrom, strTo, strSubject,"这仅仅是个简单的文本mail");
7Response.Write("Email 已经发送成功");
2.asp+发送HTML 格式的mail
请注意,这里用了另外的一种发送命令
1 @Page Language="C#"
1 @Import Namespace="System.Web.Util"
1
2MailMessage msgMail = new MailMessage();
3msgMail.To = "[email protected]";
4msgMail.Cc = "[email protected]";
5msgMail.From = "[email protected]";
6msgMail.Subject = "asp+发送HTML 格式的mail";
7msgMail.BodyFormat = MailFormat.Html;
8string strBody = "
<html><body><b>Hello World</b>" +
" <font color='"red"'>ASP+</font></body></html>
1";
2msgMail.Body = strBody;
3SmtpMail.Send(msgMail);
4Response.Write("Email 已经发送成功");
3.asp+ 发送带有 附件的Email
1 @Page Language="C#"
1 @Import Namespace="System.Web.Util"
1
2MailMessage msgMail = new MailMessage();
3msgMail.To = "[email protected]";
4msgMail.From = "[email protected]";
5msgMail.Subject = "Attachment Test";
6msgMail.BodyFormat = MailFormat.Text;
7msgMail.Body = "Check out the attachment!";
8msgMail.Attachments.Add(new MailAttachment("c:\\\temp\\\doufu.txt"));
9SmtpMail.Send(msgMail);
10Response.Write("Email 已经发送成功");
好了,看完这篇文章以后,您是不是对于Email发送在asp+中的操作已经没有问题了?哦!还有
问题,没有关系,随时留意本站的更新吧