在ASP.NET(c#)中,能够《接收和发送》邮件吧?有具体的代吗?

解决方案 »

  1.   

    .NET类库种自带有SMTP类。在.NET中的System.Web.Mail名字空间下,有一个专门使用SMTP协议来发送邮件的类:SmtpMail,它已能满足最普通的发送邮件的需求。这个类只有一个自己的公共函数--Send()和一个公共属性—SmtpServer
    您必须通过SmtpServer属性来指定发送邮件的服务器的名称(或IP地址),然后再调用
    Send()函数来发送邮件。
    代码示例如下:
    (in C#)
    using System.Web.Mail;
    public void sendMail()
    {
    try
    {
    System.Web.Mail.MailMessage myMail=new MailMessage();
    myMail.From = "[email protected]";
    myMail.To = "[email protected]";
    myMail.Subject = "MailTest";
    myMail.Priority = MailPriority.Low;
    myMail.BodyFormat = MailFormat.Text;
    myMail.Body = "Test";
    SmtpMail.SmtpServer="smarthost"; //your smtp server here SmtpMail.Send(myMail);
    }
    catch(Exception e)
    {
    throw e;
    }
    }您可以在Send函数的参数MailMessage对象中设置邮件的相关属性,如优先级、附件等等。除了以MailMessage对象为参数(如上述代码),Send函数还可以简单的直接以邮件的4个主要信息(from,to,subject,messageText)作为字符串参数来调用。
      

  2.   

    我用163的邮箱发信,属性SmtpServer应该为smtp.163.com吧
    我在vs.net中试出错
    SmtpMail.SmtpServer="smtp.163.com"; //your smtp server here
      

  3.   

    现在发送邮件都要加服务器认证语句
    MyEmailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
    MyEmailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "name");//用户名
    MyEmailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "pwd");//邮箱密码 
      

  4.   

    加在
    “SmtpMail.SmtpServer="smtp.163.com";”前面
      

  5.   

    smtp类只能发送邮件,如果既能发送也能接收,那就用tcpclient类,根据的是telnet的命令的原理.具体可搜索tcpclient类的msdn.
      

  6.   

    晕了,发不了代码 c#2.0用System.Net.Mail
      

  7.   

    SmtpMail.SmtpServer这个属性应填什么呀
      

  8.   

    SmtpMail.SmtpServer属性值应该填什么呀?
      

  9.   

    SmtpMail.SmtpServer="127.0.0.1"
    在iis下设了中继,
    现在是没有错误了,但收不到信