Skip to content

Instantly share code, notes, and snippets.

@abfo
Created October 1, 2018 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abfo/e5aeeb21d10e8d1b74cb262c3c9c1433 to your computer and use it in GitHub Desktop.
Save abfo/e5aeeb21d10e8d1b74cb262c3c9c1433 to your computer and use it in GitHub Desktop.
// Gmail Address from where you send the mail
var fromAddress = "username@gmail.com";
// any address where the email will be sending
var toAddress = YourEmail.Text.ToString();
//Password of your gmail address
const string fromPassword = "pass";
// Passing the values and make a email formate to display
string subject = YourSubject.Text.ToString();
string body = "From: " + YourName.Text + "\n";
body += "Email: " + YourEmail.Text + "\n";
body += "Subject: " + YourSubject.Text + "\n";
body += "Question: \n" + Comments.Text + "\n";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.gmail.com";
smtp.Port = 587; smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
}
// Passing values to smtp object smtp.Send(fromAddress, toAddress, subject, body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment