Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
try
        {
                        
            MailMessage mail = new MailMessage();
            mail.From = new System.Net.Mail.MailAddress("@gmail.com");            
            SmtpClient smtp = new SmtpClient();
            smtp.Port = 465;  
            smtp.EnableSsl = true;
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network; 
            smtp.UseDefaultCredentials = false;
            smtp.Credentials = new NetworkCredential("@gmail.com", ""); 
            smtp.Host = "smtp.gmail.com";
           
            mail.To.Add(new MailAddress("@gmail.com"));
            mail.IsBodyHtml = true;
            string st = "This is for testing SMTP mail from GMAIL";

            mail.Body = st;
            smtp.Send(mail);

        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
Posted
Updated 29-Sep-14 16:43pm
v2
Comments
SteveyJDay 29-Sep-14 16:52pm    
Start by adding a valid to and from address...

Next are you sure google is going to let you use their SMTP server?

1 solution

 
Share this answer
 

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