using System.Net.Mail;
using System.Net;
public static void MailSend(string ToMail, string Subject, string Content)
{
string MailSenderEmail = WebConfigurationManager.AppSettings["MailSenderEmail"];
string MailSenderName = WebConfigurationManager.AppSettings["MailSenderName"];
string MailServer = WebConfigurationManager.AppSettings["MailServer"];
string MailServerUser = WebConfigurationManager.AppSettings["MailServerUser"];
string MailServerPass = WebConfigurationManager.AppSettings["MailServerPass"];
int MailServerPort = int.Parse(WebConfigurationManager.AppSettings["MailServerPort"]);
MailAddress gonderen = new System.Net.Mail.MailAddress(MailSenderEmail, MailSenderName);
MailAddress alan = new System.Net.Mail.MailAddress(ToMail, "");
MailMessage eposta = new System.Net.Mail.MailMessage(gonderen, alan);
eposta.IsBodyHtml = true;
eposta.Subject = Subject;
eposta.Body = Content;
NetworkCredential auth = new System.Net.NetworkCredential(MailServerUser, MailServerPass);
SmtpClient SMTP = new System.Net.Mail.SmtpClient();
SMTP.Host = MailServer;
SMTP.UseDefaultCredentials = false;
SMTP.Credentials = auth;
SMTP.Port = MailServerPort;
SMTP.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
try
{
SMTP.Send(eposta);
}
catch (Exception)
{
}
}