Set this on your web config file
<system.net>
<mailsettings>
<smtp from="notifications@yourwebsite.com">
<network host="yourwebsite.com" password="1@Password" username="notifications@yourwebsite.com" port="587" />
</smtp>
</mailsettings>
</system.net>
Remember to use the following namespace
using System.Net;
using System.Net.Mail;
public static bool SendEmail(string to, string cc, string msgsubject, string msgbody)
{
try
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress("notifications@yourwebsite.com", "Testing Server");
msg.To.Add(new MailAddress(to));
msg.CC.Add(new MailAddress(cc));
msg.IsBodyHtml = true;
msg.Subject = msgsubject;
msg.Body = msgbody;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.EnableSsl = false;
mSmtpClient.Send(msg);
return true;
}
catch (Exception emsg)
{
throw emsg;
}
return false;
}