Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29927

email not sending in ASP.NET

$
0
0

Please can anyone help here: I have this asp.net form am trying to send as email and here is the code:

try 
{
    MailMessage mailSend = new MailMessage();
    mailSend.From = new MailAddress("williams@iquo.com.ng");
    mailSend.To.Add("williams@iquo.com.ng");
    mailSend.Subject = "Contact message from www.iquo.com.ng";

    mailSend.Body = "<b>My name is: </b>" + firstName.Text + lastName.Text + "<br/>" + "<b>My phone number is: </b>" + pNumber.Text + "<br/>"
    + "<b>My email address is: </b>" + email.Text + "<br/>" + "<b>The message is: </b>" + message.Text;
    mailSend.IsBodyHtml = true;

    SmtpClient smtpClient = new SmtpClient("smtp.iquo.com.ng", 25);                
    smtpClient.Credentials = new System.Net.NetworkCredential("williams@iquo.com.ng", "password");
    smtpClient.Send(mailSend);

    firstName.Enabled = false; 
    lastName.Enabled = false;
    pNumber.Enabled = false;
    email.Enabled = false;
    message.Enabled = false;
    Response.Redirect("about-me.html");
}
catch (Exception ex)
{
    throw new Exception(ex.ToString());
}

Is there anything wrong and why will the mail not sent? Also, I place this:

<system.net>
    <mailSettings>
    <smtp>
  <network host="smtp.iquo.com.ng" userName="williams@iquo.com.ng"    password="password />
  </smtp>
  </mailSettings>
</system.net>

into the the web.config file as instructed by server admin. What can I do?


Viewing all articles
Browse latest Browse all 29927


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>