Mail Sending in C#
string strSMTPServer = ConfigurationManager.AppSettings["SMTPServer"];//smtp server url
string strFromAddress = ConfigurationManager.AppSettings["FromAddress"];
//From Address of Mail
string strUserName = ConfigurationManager.AppSettings["MailCredential_UserName"];
string strPassword = ConfigurationManager.AppSettings["MailCredential_Password"];
int intSMTPPort = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]);
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(strSMTPServer);
mail.From = new MailAddress(strFromAddress);
mail.To.Add(ConfigurationManager.AppSettings["ToAddress"]);
mail.Subject = "Subject of Mail here";
mail.Body = "Body of mail here" ;
SmtpServer.Port = intSMTPPort;
SmtpServer.Credentials = new System.Net.NetworkCredential(strUserName, strPassword);
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
lblLoginError.Text = "Password Sent Successfully";
No comments:
Post a Comment