Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
try
            {

                MailAddress mailfrom = new MailAddress("sankarreddyece@gmail.com");
                MailAddress mailto = new MailAddress(TextBox3.Text);
                MailMessage newmsg = new MailMessage(mailfrom, mailto);

                newmsg.Subject = "Subject of Email";
                newmsg.Body = "Body(message) of email";

                ////For File Attachment, more file can also be attached

                //Attachment att = new Attachment ( "G:\\code.txt" );
                //newmsg.Attachments.Add ( att );

                SmtpClient smtps = new SmtpClient("smtp.gmail.com", 587);
                smtps.UseDefaultCredentials = false;
                smtps.Credentials = new System.Net.NetworkCredential("sankarreddyece@gmail.com", "640");
                smtps.EnableSsl = true;
                smtps.Send(newmsg);
                //MessageBox.Show("mail Send");

            }

I will try this coding its does not show any error.email also not sent what will be problem.
Posted
Updated 7-Mar-12 13:58pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900