Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

unable to send mail

$
0
0

i want to send sms from asp.net application . i have written this code for sending mail .

<div>
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("amitverma1150@gmail.com","Amit Kumar");
            myMessage.To.Add(new MailAddress("amitverma0511@gmail.com", "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;
        }
</div><div></div><div> but after clicking on submit button i get a exception like "unable to sent the feedback .Check your smpt server"</div><div>i also configured smpt setting in web.config file
<div>
<system.net><mailSettings><smtp from="amitverma0511@gmail.com"><network host="smtpout.secureserver.net" password="myemailpassword" userName="amitverma0511@gmail.com"/></smtp></mailSettings></system.net>
</div> </div>

Viewing all articles
Browse latest Browse all 23244

Trending Articles



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