Repeated Reminder Mail Sending from ASP.NET Application

Posted by Sasikala under ASP.NET on 5/16/2013 | Points: 10 | Views : 10090 | Status : [Member] | Replies : 3
Hi all,
My ASP.NET coding has to check a table in SQL Server DB for Finish Date column. The column value has to be assigned by responsible person of that particular task within 4 days from the day of assigning, otherwise from 5th day a reminder mail has to be sent for that responsible person until Finish Date column is given value. Responsible person may be one or more persons, so to all the mail has to be sent. I'm using .NET 2012 and SQL Server 2008 R2. How to perform it? Anybody have solution for this, How to code???




Responses

Posted by: Chpraveen31 on: 5/18/2013 [Member] Starter | Points: 25

Up
0
Down
better to use windows service to do this

or u can use below method
http://www.c-sharpcorner.com/uploadfile/17e8f6/sending-automatic-mails-in-Asp-Net/
http://www.c-sharpcorner.com/uploadfile/17e8f6/sending-automatic-mail-through-Asp-Net/

these articles may useful to you
or you can go with this article
http://www.codeproject.com/Articles/12117/Simulate-a-Windows-Service-using-ASP-NET-to-run-sc


But some Cons are there with these methods

Praveen Kumar Ch (.Net Develper)

Sasikala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sasikala on: 5/19/2013 [Member] Starter | Points: 25

Up
0
Down
I have already seen these two links, but this is not what I want, because it works only when button is clicked, my program has to auto check the finish date column and automatically send mail to concerned persons.

Sasikala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 5/20/2013 [Member] Starter | Points: 25

Up
0
Down
you can get idea from my program, actualy in this code i checked for the table whose status is pending if status is pending then automatic mail has to be generate
public void remindermail()

{
db.myconnection();
SqlCommand cmd = new SqlCommand("select * from leavereminder", db.sqlcon);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
//take query result in datatable
DataTable dt = new DataTable();
adp.Fill(dt);
if (dt.Rows.Count > 0)
{
//check for the table field value
if (dt.Rows[0]["status"].ToString() == "pending")
{
/*string femail = dt.Rows[0]["email"].ToString();
string name = dt.Rows[0]["name"].ToString();*/
//send mail
sendmail(dt.Rows[0]["email"].ToString(), dt.Rows[0]["name"].ToString());
}
else if (dt.Rows[0]["status"].ToString() == "approved")
{
sendmail(dt.Rows[0]["email"].ToString(), dt.Rows[0]["name"].ToString());

}

}

}
public void sendmail(string email, string name)
{
db.myconnection();
StreamReader reader = new StreamReader(Server.MapPath("~/HTMLPage.htm"));
string readFile = reader.ReadToEnd();
string myString = "";
myString = readFile;
myString = myString.Replace("$$Admin$$", name);
myString = myString.Replace("$$CompanyName$$", "cnet infotech");

MailMessage msg = new MailMessage();
msg.From = new MailAddress("ankitsaxena22@rediffmail.com");
msg.To.Add(email);
msg.Subject = "appy budday";

msg.Body = myString.ToString();
msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("", "");
smtp.EnableSsl = true;
smtp.Send(msg);

}


Sasikala, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response