Send mail directly using button
how to send mail directly on button click
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sanwar RanwaRank #23 · 44.7K reputationPosted Feb 25, 2019, 9:36 PM EST
Salman BegRank #284 · 8.8K reputationPosted Feb 26, 2019, 3:41 AM EST
Siddhartha SharmaRank #2,254 · 626 reputationPosted Mar 18, 2019, 7:40 PM EDT
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient();
message.From = new MailAddress("FromMailAddress");
message.To.Add(new MailAddress("ToMailAddress"));
message.Subject = "Test";
message.IsBodyHtml = true; //to make message body as html
message.Body = htmlString;
smtp.Port = 587;
smtp.Host = "smtp.gmail.com"; //for gmail host
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("FromMailAddress", "password");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(message); // Mail sent
use above methodRajeesh MenothRank #118 · 18.4K reputationPosted Mar 18, 2019, 8:15 PM EDT
Md SarfarajRank #194 · 12.4K reputationPosted Mar 22, 2019, 6:19 AM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Mar 22, 2019, 6:34 AM EDT