You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.3 KiB

using JMETxnPushScheduler.Repository;
using System;
using System.Data;
namespace JMETxnPushScheduler.Business
{
public class SendEmail
{
SendRepository _repository = new SendRepository();
public void mailsend()
{
int i = 1;
DataTable mailDetails = _repository.GetMailDetails();
string msgSubject = "About pasword Reset";
string msgBody = string.Empty;
if (mailDetails == null )
{
return;
}
else if (mailDetails.Rows.Count == 0)
{
return;
}
try
{
msgBody = "<html><head><meta content=text/html; charset=utf-8 http-equiv=Content-Type></head><body><table>" +
"<tr><td><b>SNo.&nbsp;</b></td>" +
"<td><b>Full Name</b></td>" +
"<td><b>Email</b></td>" +
"<td><b>User Name</b></td>" +
"<td><b>New Password</b></td>" +
"</tr>";
foreach (DataRow item in mailDetails.Rows)
{
msgBody += "<tr><td>" + Convert.ToString(i ) + "</td>";
msgBody += "<td>" + item["Name"].ToString() + "</td>";
msgBody += "<td>" + item["Email"].ToString() + "</td>";
msgBody += "<td>" + item["UserName"].ToString() + "</td>";
msgBody += "<td>" + item["Newpassword"].ToString() + "</td>";
i = i + 1;
}
msgBody += "</table></body></html>";
SmtpMailSetting mail = new SmtpMailSetting
{
MsgBody = msgBody,
MsgSubject = msgSubject,
ToEmails = GetStatic.ReadWebConfig("recivermail", "")
};
string res = mail.SendSmtpMail(mail);
//if (res != "Mail Send")
//{
// ErrorEmail();
//}
}
catch (Exception ex)
{
ex.Message.ToString();
}
}
public void ErrorEmail()
{
_repository.ErrorEmail();
}
}
}