问题如下:
   如何用.NET开发邮件发送功能的模块?
   就是有什么类,用什么方法可以把一段文字以电子邮件的形式发送到指定的IP上?
   谢谢.

解决方案 »

  1.   

    是的.
    我再说的仔细些.
    要我开发一个系统:
       用户把某个文件传送到几个同事处,方法就是发电子邮件告诉他们文件在啊里,
       所以现在的问题就是在ASP.NET中用什么代码能把一封自定义的邮件发出去.
      

  2.   

    自己写的话,用System.Web.Mail中。MSDN上有示例要现在所写好的。我这里有,发给你一份吧。或者在论坛上搜一下
    前几天有发过的。我就是里从那里下载的。。
      

  3.   

    using System.Web.Mail ;  private void SendButton_Click(object sender, System.EventArgs e) 
     { 
      try 
      { 
      MailMessage Message = new MailMessage ( ) ; 
      //新建一个MailMessage对象 
      Message.From = textBox1.Text ; 
      //定义发信人地址 
      Message.To = textBox2.Text ; 
      //定义收信人地址,如果是多人,可以用“,”分开 
      Message.Subject = textBox3.Text ; 
      //定义邮件的主题 
      Message.Body = textBox4.Text ; 
      //定义邮件的内容 
      if ( openFileDialog1.FileName != "" ) 
      { 
       MailAttachment Attachment = new MailAttachment ( openFileDialog1.FileName ,MailEncoding.Base64 ) ; 
       //以Base64编码创建一个附件实例 
       Message.Attachments.Add ( Attachment ) ; 
       //给邮件增加附件 
      } 
      //判断要发送的邮件是否有附件,如果有则加入 
      SmtpMail.Send ( Message ) ; 
      //发送电子邮件 
      MessageBox.Show( "电子邮件已经发送到->" + textBox2.Text ) ; 
      } 
      catch ( Exception ex ) 
      { 
      MessageBox.Show ( ex.Message.ToString ( ) ) ; 
      } 
     } 
      

  4.   

    public void CDOsendMail()
    {
     try
     {    
      CDO.Message oMsg = new CDO.Message();
        
      oMsg.From = "[email protected]";
      oMsg.To = "[email protected]";
      oMsg.Subject = "MailTest";
                     
      oMsg.HTMLBody = "<html><body>Test</body></html>";  CDO.IConfiguration iConfg = oMsg.Configuration;
      ADODB.Fields oFields = iConfg.Fields;
              
    oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value=2;
    oFields["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"].Value="[email protected]"; //sender mail
    oFields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"].Value="[email protected]"; //email account
    oFields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value="username";
    oFields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value="password"; 
    oFields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value=1;
    //value=0 代表Anonymous验证方式(不需要验证)
    //value=1 代表Basic验证方式(使用basic (clear-text) authentication. 
    //The configuration sendusername/sendpassword or postusername/postpassword fields are used to specify credentials.)
    //Value=2 代表NTLM验证方式(Secure Password Authentication in Microsoft Outlook Express)
    oFields["http://schemas.microsoft.com/cdo/configuration/languagecode"].Value=0x0804;
    oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value="smtp.21cn.com";  oFields.Update();
      oMsg.BodyPart.Charset="gb2312";
      oMsg.HTMLBodyPart.Charset="gb2312";   oMsg.Send();
      oMsg = null;
     }   
     catch (Exception e)
     {
      throw e;
     }
    }