CSDN博客

img bineon

一个.NET发邮件的简单例子

发表于2004/7/15 23:55:00  1281人阅读

    //from:http://blog.csdn.net/superch0054/archive/2004/07/15/Mail.aspx 

    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>");

0 0

相关博文

我的热门文章

img
取 消
img