ASP.NET发送EMAIL,急急急,为什么我发送不成功。而且cpu 竟然到了100%。问题解决立马给分
string Webmaster=ConfigurationSettings.AppSettings["Webmaster"];
string SMTP=ConfigurationSettings.AppSettings["SMTP"]; MailMessage Mailer=new MailMessage(); Mailer.From=Webmaster;
Mailer.To=user.Email; Mailer.Subject="员工取回密码";
Mailer.Body="你的员工编号为:"+txtFBM.Text+
         "\n 密码为:"+user.Password;
Mailer.BodyFormat=System.Web.Mail.MailFormat.Text;
Mailer.Priority=MailPriority.High; SmtpMail.SmtpServer=SMTP;
SmtpMail.Send(Mailer); Message.Text="密码已经发送成功!";
Message.ForeColor=Color.Blue;

解决方案 »

  1.   

    有的不支持匿名邮件:
    //发送
    //MailMessage mail = new MailMessage();
    //mail.To = "[email protected]";
    //mail.From = "[email protected]";
    //mail.Subject = "this is a test email.";
    //mail.Body = "Some text goes here";
    //
    //mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
    //mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username"); //set your username here
    //mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");//set your password here
    //
    //SmtpMail.SmtpServer = "smtp.sohu.com";//your real server goes here
    //
    //SmtpMail.Send( mail );
      

  2.   

    用命名空間Imports System.Web.Mail
    以下可參考:
     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here       
            Dim mail As New MailMessage
            Dim iLoop1 As Integer
            Dim sAttach As String = "c:\usblog.txt"
            Dim delim As Char = ","        Dim sSubstr As String
            mail.To = "[email protected]"
            mail.Cc = ""
            mail.From = "HAHA"
            mail.Subject = "this is a test email."
            mail.BodyFormat = MailFormat.Html
            mail.Body = "Some text goes here!"        For Each sSubstr In sAttach.Split(delim)
                Dim myAttachment As MailAttachment = New MailAttachment(sSubstr)
                mail.Attachments.Add(myAttachment)
            Next
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "0") 'basic authentication        
            SmtpMail.SmtpServer = "192.168.203.9" 'your real server goes here
            SmtpMail.Send(mail)
        End Sub
      

  3.   

    using System.Web.Mail;
    MailMessage mm=new MailMessage();
    mm.From="[email protected]";
    mm.To="[email protected]";
    mm.Subject=this.TextBox3.Text;
    mm.Body=this.TextBox1.Text+"   "+this.TextBox4.Text; mm.Fields.Add(@"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //表示基本验证
    mm.Fields.Add(@"http://schemas.microsoft.com/cdo/configuration/sendusername", "abcabc"); //在my_username_here处添加如163这样的身份验证的用户名
    mm.Fields.Add(@"http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456"); // 在your_password_here处输入密码
    SmtpMail.SmtpServer = "smtp.163.com";  //邮件服务器地址
    SmtpMail.Send(mm);
      

  4.   

    to: cocoguo(周周) 程序可以运行,但是运行到SmtpMail.Send(mm);这句语句时,电脑就跟死了一样,cpu变成100%,接下去就不动了。。
      

  5.   

    加上这个试试
    try
    {
    SmtpMail.Send(mm);
    }
    catch
    {
    Response.Write("<script>window.alert('"+"发生故障,邮件没有发送成功"+"')</script>");
    return;

    }
    Response.Write("<script>window.alert('"+"邮件发送成功"+"')</script>");
      

  6.   

    打开IIS管理工具,右击“默认SMTP虚拟服务器”==》属性==》==》访问==》中继==》添加
    在IP地址里输入127.0.0.1 确定
      

  7.   

    那个不支持身份验证的,很不爽.兄弟还是用别的办法吧,比如CDO组件或JMAIL等