Wednesday 23 November 2016

Send E-mail From C# Code Some

Step need to Follow
Problem Solutions on Issue Related

try
        {
            MailMessage Msg = new MailMessage();
            // Sender e-mail address.
            Msg.From = new MailAddress(txtemail.Text);
            // Recipient e-mail address.
            Msg.To.Add("kiit.kurukshetra@gmail.com");
            Msg.Subject = "Message From Website by: " + txtname.Text + " Contact him at " + txtmob.Text+" Facbook id "+txtfbid.Text+" E-mail: "+txtemail.Text;
            Msg.Body = txtmessage.Text + "<br/> Message From:" + txtname.Text + ", Address: " + txtadd.Text;
            // your remote SMTP server IP.
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.Credentials = new System.Net.NetworkCredential("nickkr27@gmail.com", "kkr1234567");
            smtp.EnableSsl = true;
            smtp.Send(Msg);
            Msg = null;
            lbltxt.Text = "Sent Get Back you soon";
         
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }