ASP

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentASP

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old August 23rd, 2010, 09:56 PM
greenCat greenCat is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2010
Posts: 1 greenCat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 15 sec
Reputation Power: 0
Automatic email notification

Hello everyone..I'm newbie in asp and i need ur help.

I done developed asp system but i'm try to add new features..what i want to do is sending automatic email notification when user do nothing mean they not login for >3day.. so the system will send email to them..anyone know how to develop..

thank you

Reply With Quote
  #2  
Old December 7th, 2016, 12:54 AM
dishagandhi dishagandhi is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Dec 2016
Location: Ahmedabad
Posts: 52 dishagandhi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 40 m 42 sec
Reputation Power: 2
If you want to send automatic email notification to specific user, then you have to use WINDOW SERVICE.
In Window service you have to create one method and set fixed time for send mail in APP.CONFIG.

Try this code:

Code:
private void Sendmail(object e)
{
    try
    {
        DataTable dt = new DataTable();
        string query = "SELECT Name, Email FROM EmployeeWHERE DATEPART(DAY, AnniversaryDate) = @Day AND DATEPART(MONTH, AnniversaryDate) = @Month";
        string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
        using (SqlConnection con = new SqlConnection(constr))
        {
            using (SqlCommand cmd = new SqlCommand(query))
            {
                cmd.Connection = con;
                cmd.Parameters.AddWithValue("@Day", DateTime.Today.Day);
                cmd.Parameters.AddWithValue("@Month", DateTime.Today.Month);
                using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
                {
                    sda.Fill(dt);
                }
            }
        }
        foreach(DataRow row in dt.Rows)
        {
            string name = row["Name"].ToString();
            string email = row["Email"].ToString();
            WriteToFile("Trying to send email to: " + name + " " + email);
 
            using (MailMessage mm = new MailMessage("sender@gmail.com", email))
            {
                mm.Subject = "Anniversary Greetings";
                mm.Body = string.Format("<b>Happy Anniversary </b>", name);
 
                mm.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.EnableSsl = true;
                System.Net.NetworkCredential credentials = new System.Net.NetworkCredential();
                credentials.UserName = "sender@gmail.com";
                credentials.Password = "<Password>";
                smtp.UseDefaultCredentials = true;
                smtp.Credentials = credentials;
                smtp.Port = 587;
                smtp.Send(mm);
                WriteToFile("Email sent successfully to: " + name + " " + email);
            }
        }
        this.ScheduleService();
    }
    catch (Exception ex)
    {
        WriteToFile("Simple Service Error on: {0} " + ex.Message + ex.StackTrace);
 
        //Stop the Windows Service.
        using (System.ServiceProcess.ServiceController serviceController = new System.ServiceProcess.ServiceController("SimpleService"))
        {
            serviceController.Stop();
        }
    }
}

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentASP > Automatic email notification


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap