Note that there are some explanatory texts on larger screens.

plurals
  1. POFailure sending Mail in asp.net mvc4 smtp.Send(mail)
    text
    copied!<p>I find out number of posts regarding to this Issue in stackoverflow, But Still my problem was not solved. I tried to send a mail using the below code: </p> <p><strong>In Controller:</strong></p> <pre><code>try { MailMessage mail = new MailMessage(); mail.To.Add("mailto@gmail.com"); mail.From = new MailAddress("mailfrom@gmail.com"); mail.Subject = "Feedback for Website"; string Body = "Name:"; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; smtp.Credentials = new System.Net.NetworkCredential("mailTo@gmail.com", "topassword"); smtp.Send(mail); } catch (Exception ex) { Response.Write(ex.Message); } </code></pre> <p><strong>web.config:</strong></p> <pre><code>&lt;system.net&gt; &lt;mailSettings&gt; &lt;smtp deliveryMethod="PickupDirectoryFromIis"&gt; &lt;network defaultCredentials="true" host="localhost" port="25"/&gt; &lt;/smtp&gt; &lt;/mailSettings&gt; </code></pre> <p></p> <p>I tried this also:</p> <pre><code>&lt;smtp from="mymail@gmail.com"&gt; &lt;network enableSsl="true" host="smtp.gmail.com" port="587" userName="mymail@gmail.com" password="mypassword" /&gt; </code></pre> <p></p> <p>While debugging In my output:</p> <pre><code>Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.MailMessage' Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.To.get' Step into: Stepping over non-user code 'System.Net.Mail.MailAddress.MailAddress' Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.Subject.set' Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.Body.set' Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.IsBodyHtml.set' Step into: Stepping over non-user code 'System.Net.Mail.SmtpClient.SmtpClient' Step into: Stepping over non-user code 'System.Net.Mail.SmtpClient.Host.set' Step into: Stepping over non-user code 'System.Net.Mail.SmtpClient.EnableSsl.set' The thread '&lt;Thread Ended&gt;' (0x1f38) has exited with code 0 (0x0). 'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll' Step into: Stepping over non-user code 'System.Net.NetworkCredential.NetworkCredential' The thread '&lt;No Name&gt;' (0x23d8) has exited with code 0 (0x0). Step into: Stepping over non-user code 'System.Net.Mail.SmtpClient.Send' A first chance exception of type 'System.Net.Mail.SmtpException' occurred in System.dll The thread '&lt;Thread Ended&gt;' (0x1474) has exited with code 0 (0x0). </code></pre> <p>How to solve this.. Please help me.. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload