一个.NET发邮件的简单例子
using System.Web.Mail;
MailMessage msgMail = new MailMessage();
msgMail.To=Tsendto.Text.Trim();
msgMail.Cc = "webmaster@aspcool.com";
msgMail.From = Tsendfrom.Text.Trim();
msgMail.Subject = "Congraculations!";
msgMail.Priority = MailPriority.High;
msgMail.BodyFormat = MailFormat.Html; //加这一句,可以发html邮件
string strBody =Tcontext.Text.Trim();
msgMail.Body = strBody;
msgMail.Attachments.Add(new MailAttachment("e://aaa.jpg"));
SmtpMail.SmtpServer = "mail.zhhz.org";
msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here
SmtpMail.Send(msgMail);
Response.Write("<script>alert('发送成功')</"+ "script>");