Theone

TheOne的Bolgs

 

smtp验证发邮件,今天好郁闷,终于解决了

需要添加引用“Microsoft CDO for Windows 2000 Library“

using CDO;
using System.Web.Mail;


MailMessage mail = new MailMessage();
   mail.To = " to@mail.com";
   mail.From = "from@mail.com";
   mail.Subject = "this is a test email.";
   mail.Body = "Some text goes here";
   mail.Fields.Add(CdoConfiguration.cdoSMTPAuthenticate, "1"); 
   mail.Fields.Add(CdoConfiguration.cdoSendUserName, "username"); //用户名
   mail.Fields.Add(CdoConfiguration.cdoSendPassword, "pass"); //密码

   SmtpMail.SmtpServer = "smtp.263.net";  //smtp邮件服务器
   try
   {
    SmtpMail.Send(mail);
   }
   catch(System.Runtime.InteropServices.COMException e1)
   {
    Response.Write(e1.ToString());
   }

 

参考

http://www.csdn.net/Develop/Read_Article.asp?Id=14850
http://blog.joycode.com/joy/posts/11405.aspx

posted on 2004-05-10 17:12  Theone  阅读(3008)  评论(2编辑  收藏  举报

导航