KnowledgebaseHow can we help you?

Included Namespace.
using System.Net;
using System.Net.Mail;

After adding Namespace use below code


protected void SendMail() { var fromAddress = "frome@domain.com"; // any address where the email will be sending var toAddress = "to@gmail.com"; //Password of your email address const string fromPassword = "Password"; // 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 = "mail.domain.com"; smtp.Port = 25; smtp.EnableSsl = false; 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); }

Was this answer helpful?

Also Read



+91 9429692542
10:00 am to 7:30 pm IST Monday to Saturday
Live Chat, Email and Tickets are available 24/7

HostAdvice Great Uptime Award for Gen X Web Hosting
Gen X Web Hosting Reviews