Arkadaşlar merhaba
Asp.net (framework 4.5.2) üzerinde yaptığım projede gridview içeriğini html çevirip mail olarak göndermek istiyorum
kodlarım şu şekilde;
protected void Button8_Click1(object sender, EventArgs e)
{
MailMessage mailMsg = new MailMessage();
mailMsg.IsBodyHtml = true;
mailMsg.Subject = "Cari Ekstre";
StringBuilder SB = new StringBuilder();
StringWriter SW = new StringWriter(SB);
HtmlTextWriter htmlTW = new HtmlTextWriter(SW);
GridView1.RenderControl(htmlTW);
mailMsg.Body = SB.ToString();
mailMsg.From = new MailAddress("gönderen mailadresi ");
mailMsg.To.Add(TextBox8.Text);
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("gönderen mail adresi", "şifre");
smtp.EnableSsl = true;
smtp.Send(mailMsg);
lblStatus.Text = "Mail Gönderildi";
}
public override void VerifyRenderingInServerForm(Control control) { }
}
}
Localde sorunsuz çalışıyor mail gönderiyor fakat sunucuya yüklediğimde aşağıdaki hatayı alıyorum neden kaynaklanabilir?
Hata kodu aşağıdaki şekilde;
Server Error in '/' Application.
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at]
System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) +1525339
System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode) +46
System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception) +88
System.Net.Mail.SmtpClient.Send(MailMessage message) +1852
WebApplication7.WebForm4.Button8_Click1(Object sender, EventArgs e) +474
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9628114
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34209
Gönderildi : 25/02/2015 15:25