谁有ASP.NET通过SMTP服务器发送邮件的代码啊,可以成功发送的,我都找了N久还是没有可以用的!谢谢了

解决方案 »

  1.   

    安装smtp,pop3服务然后在pop3,属性里建立邮箱帐号。
    然后在asp.net 的web.config里配置下就可以了欢迎访问我的视频搜索引擎:http://www.vzhangmen.com
      

  2.   

    我的意思是借助在比如像126这样的已经有的免费邮箱发送
    还有个问题就是,我用HTML的FILEFILD控件添加邮件附件,提示没有访问权限,我给了ASPNET权限后可以了,如果我把程序放虚拟空间上,访问我网站的人需要这样设置吗?126的邮箱好像不需要设置就可以添加附件的!
      

  3.   


            System.Net.Mail.SmtpClient client = new SmtpClient("smtp.163.com");
            client.UseDefaultCredentials = false;
            client.Credentials = new System.Net.NetworkCredential("user", "pwd");
            client.DeliveryMethod = SmtpDeliveryMethod.Network;        System.Net.Mail.MailMessage message = new MailMessage("发件人", "收件人", "标题", "内容");
            
            //message.BodyEncoding = System.Text.Encoding.UTF8;
              message.BodyEncoding = Encoding.GetEncoding("GB2312");
                    message.SubjectEncoding = Encoding.GetEncoding("GB2312");
            message.IsBodyHtml = true;
            client.Send(message);
      

  4.   

    你也可以借助CDO发信,网上有代码,自己找
      

  5.   

    asp.net2.0 public static bool SendEmail(
                string server, int port,
                string user, string pass,
                System.Net.Mail.MailMessage mail
                )
     {
                System.Net.Mail.SmtpClient client = new SmtpClient(server, port);
                client.DeliveryMethod = SmtpDeliveryMethod.Network;//指定发送方式 Network是直接用smtp发送
                client.Credentials = new System.Net.NetworkCredential(user, pass);
                client.Send(mail);
                return true;
     }
      

  6.   

    建议你用jmail发送其他的发送方式需要你探索,不是不能成功,可能会比较麻烦。要是用jmail就很容易,而且基本你看看就可以成功发送了。
    具体代码就不写了。一搜索就有了
      

  7.   

    建议你用CDO发送是微软的, m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication 
                    m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", mailname); //set your username here 
                    m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", mailpwd); //set your password here 
                    SmtpMail.SmtpServer = smtp;