Amit Kumar

Amit Kumar

  • NA
  • 140
  • 40.9k

unable to send mail

Sep 19 2013 8:23 AM
i want to send sms from asp.net application . i have written this code for sending mail .
try
        {
            string filename = Server.MapPath("~/App_Data/FeedBack.txt");
            string mailbody = System.IO.File.ReadAllText(filename);
            mailbody = mailbody.Replace("##Name##", txtName.Text);
            mailbody = mailbody.Replace("##Email##",txtEmail.Text);
            mailbody = mailbody.Replace("##contact##",txtContact.Text);
            mailbody = mailbody.Replace("##Commnect##",txtSuggestion.Text);
            MailMessage myMessage = new MailMessage();
            myMessage.Subject = "Responce from website";
            myMessage.Body = mailbody;
            myMessage.From = new MailAddress("[email protected]","Amit Kumar");
            myMessage.To.Add(new MailAddress("[email protected]", "Amit Verma"));
            SmtpClient mysmptclient = new SmtpClient();
            mysmptclient.Send(myMessage);
            formatTable.Visible = false;
            lblMail.Text = "Your Feedback has been sent successfully";
            lblMail.ForeColor = Color.Green;

        }
        catch
        {
            lblMail.Text = "unable to sent the feedback .Check your smpt server";
            lblMail.ForeColor = Color.Red;
        }

 but after clicking on submit button i get a exception like "unable to sent the feedback .Check your smpt server"
i also configured smpt setting in web.config file
<system.net>
  <mailSettings>
    <smtp from="[email protected]">
      <network host="smtpout.secureserver.net" password="myemailpassword" userName="[email protected]"/>
    </smtp>
  </mailSettings>
</system.net>


Answers (2)