MailMessage msg = new MailMessage(); SmtpClient client = new SmtpClient("smtp.gmail.com",587); client.EnableSsl = true; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential("myid@gmail.com","mypassword"); client.DeliveryMethod = SmtpDeliveryMethod.Network; msg.To.Add(new MailAddress("toid@yahoo.co.in")); msg.From = new MailAddress("myid@gmail.com"); msg.Subject = "Test Mail"; msg.Body = "Body Of the E-mail"; try { client.Send(msg); MessageBox.Show("Sent"); } catch (Exception ex) { MessageBox.Show("Error: " + ex); this.Dispose(); }
Goto Account of Gmail , then select Connected apps & sites Allow less secure apps: ON(if this is off you cannot send mails through apps,or your websites )
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)