using System.Net.Mail;
using System.Net;
public void SendEmail(string name, string email, string subjectemail, string message)
{
// Gmail Address from where you send the mail
var fromAddress = "emailid@gmail.com";
// any address where the email will be sending
var toAddress = "chetan0389@gmail.com";
//Password of your gmail address
const string fromPassword = "yourpassword";
// Passing the values and make a email format to display
string subject = subjectemail;
string body = "From: " + "" + "\n";
body += "Email: " + email + "\n";
body += "Subject: " + subject + "\n";
body += "Message: \n" + message + "\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);
}
.thank you.
ReplyDeleteweb programming tutorial
welookups