Send Automated Email ASP.NET C# RRS feed

  • Question

  • User-1901014284 posted


    I am trying to setup an automated email to be sent on a daily or weekly basis by using just ASP.NET C#. Please see below the code I have so far.

    Global.asax page:
     void Application_Start(object sender, EventArgs e)
                // Code that runs on application startup
                Timer myTimer = new System.Timers.Timer();
                // Set the Interval to 5 seconds (5000 milliseconds).
                myTimer.Interval = 5000;
                myTimer.AutoReset = true;
                myTimer.Elapsed += new ElapsedEventHandler(myTimer_Elapsed);
                myTimer.Enabled = true; 
            public void myTimer_Elapsed(object source, System.Timers.ElapsedEventArgs e)
                clsScheduleMail objScheduleMail = new clsScheduleMail();
    clsScheduleMail.cs page:
        public class clsScheduleMail
            public clsScheduleMail()
            public void SendScheduleMail()

    The details I would like to send are stored within a GridView on a separate page, please see below code:

    private void BindGrid()
                using (var commandhol = con.CreateCommand())
                    DataTable dt = new DataTable();
                    SqlCommand cmd = new SqlCommand("Docs", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = ID;
                    using (var commandeh = con.CreateCommand())
                        DataTable dta = new DataTable();
                        SqlCommand myCmdeh = new SqlCommand("Portal_HS_ExpiringDocs", con);
                        myCmdeh.CommandType = CommandType.StoredProcedure;
                        SqlDataAdapter daeh = new SqlDataAdapter(myCmdeh);
                        myCmdeh.Parameters.Add("@ID", SqlDbType.VarChar).Value = ID;
                        GV.DataSource = dta;

    I would like to populate the automated email with the information from the GridView (GV) but I am not sure how I will be able to do this?

    Any help would be greatly appreciated.

    Many thanks in advance


    Wednesday, August 28, 2019 1:18 PM

All replies