SmtpClient client = new SmtpClient(); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = true; client.Host = "smtp.gmail.com"; client.Port = 587; System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("my account in gmail", "my password"); client.UseDefaultCredentials = false; client.Credentials = credentials; System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); msg.To.Add("test@yahoo.com"); msg.From = new MailAddress(textfrom.Text); msg.Subject = txtSubject.Text; msg.IsBodyHtml = true; msg.Body = textbody.text; try { client.Send(msg); Label1.Text = "Your message has been successfully sent."; } catch (Exception ex) { Label1.ForeColor = Color.Red; Label1.Text = "Error occured while sending your message." + ex.Message; } }
msg.From = new MailAddress(fromAddress, fromDisplay, Encoding.UTF8);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)