返回首页

我想配置使用C#的邮件。
这里是我的代码,我得到上述错误
。请帮我解决这个问题。

public bool Send()

    {

        string user = ConfigurationManager.AppSettings["email_username"].ToString();

        string password = ConfigurationManager.AppSettings["email_password"].ToString();

        SmtpClient SmtpServer = new SmtpClient();

        SmtpServer.Credentials = new System.Net.NetworkCredential(user, password);

	SmtpServer.Port = 25;

	SmtpServer.Host = "smtp.rediffmail.com";

        SmtpServer.EnableSsl = true;

        MailMessage mail = new MailMessage();

        try

        {

 

            mail.From = new MailAddress(user, "SUBJECT", System.Text.Encoding.UTF8);

            mail.To.Add(new MailAddress(to));

            mail.Subject = subject;

            mail.Body = message;

            mail.IsBodyHtml = true;

            mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

            mail.ReplyTo = new MailAddress(frm);

            SmtpServer.Send(mail);

 

        }

        catch (Exception err)

        {	

	return false;

	}

	return true;

    }

预先感谢| biswarup88:爱德华・卢

回答

评论会员:Vasim889 时间:2012/02/07
SmtpServer.Port = 25;
你wiil使用Gmail帐户发送邮件,bcoz没有SMTP问题尝试,然后测试你rediff accounts.k:ashutosh19841984
评论会员:游客 时间:2012/02/07
喜请更改为codeprelang="cs"SmtpServer.EnableSsl=spanclass="code-keyword"true/span;/pre/code}到codeprelang="cs"SmtpServer.EnableSsl=spanclass="code-keyword"false/span;/pre/code的{BR您的服务器似乎没有配置安全连接的SSL。改变上面的代码,邮件应该开始。感谢Ashutosh说塔瓦