爱博

专业性的个人博客...

导航

C# asp.net:广域网中邮件发送的代码实现

public void SendMail()
  {
   try
   {
    MailMessage MM=new MailMessage();
    MM.From=this.EmailFrom.Text; //发送方地址
    MM.To=this.EmailTo.Text; //接收方地址
    MM.Subject=this.EmailSubject.Text; //主题
    MM.Body=this.EmailBody.Text; //内容

   
    //设置为需要用户验证
    MM.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");  
    //设置验证用户名(把emailaddress改为你的验证用户名)
    MM.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "emailaddress"); 
    //设置验证密码(把password改为你的验证密码)
    MM.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");
 
    //MM.Fields.Add("http://
 
    SmtpMail.SmtpServer = "smtp.163.com";  //邮件服务器地址
    SmtpMail.Send(MM);

   }
   catch(Exception ex)
   {
    throw (ex);
   }

  我的几个网友问:在广域中怎么发送邮件....我在这里实现了.并给出一代码.同时为大家共享一下.希望对大家有所帮助..

posted on 2005-12-08 22:12  Sandy  阅读(580)  评论(5)    收藏  举报