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);
}
The instructions provided in this section were verified against Android 4.4.2. To set up a mail... Read More
In order to create an email account in Plesk, follow the steps given below: 1. Login to Plesk.... Read More
To set up Microsoft Office Outlook 2010: Open Microsoft Office Outlook 2010. Go to File >... Read More
The instructions provided in this section were verified against Apple Mail 8.2. They might not... Read More
The instructions provided in this section were verified against iPhone 5s. To set up a mail... Read More