public ActionResult EmailCsv(string id, string numberofdays, string dayofweek)
        {
            if (id != _csvReportId) return null;

            string msg = null;
            bool success = false;
            var today = DateTime.Today;

            try
            {
                int dof = 0;
                if (!string.IsNullOrEmpty(dayofweek) && !int.TryParse(dayofweek, out dof))
                {
                    msg = "Invalid dayofweek parameter: " + dayofweek;
                    Logger.Log(LogLevel.Error, msg);
                    Response.Write(msg);
                    return null;
                }

                // date to execute: 0 today, 1 Sunday, 2 Monday, 3 Tuesday, 4 Wednesday, 5 Thursday, 6 Friday, 7 Saturday
                if (dof != 0 && dof != (int)today.DayOfWeek + 1) return null;

                // number of days csv report will include in the data, default to 7 days
                int days = 7;
                if (!string.IsNullOrEmpty(numberofdays) && !int.TryParse(numberofdays, out days))
                {
                    msg = "Invalid numberofdays parameter: " + numberofdays;
                    Logger.Log(LogLevel.Error, msg);
                    Response.Write(msg);
                    return null;
                }

                var startDate = today.AddDays(-days);

                var report = new CsvReport(QuestionCache.AssessmentName, _csvReportViewName);
                string csv = report.ToCSV(_cultureName, startDate, today);
                string fileName = FormatCsvReportFileName(startDate, today.AddDays(-1));

                var smtpMail = new SmtpMail();
                success = smtpMail.SendCsvReport(csv, fileName);
            }
            catch (Exception e)
            {
                msg = e.Message;
                Logger.Log(LogLevel.Error, msg);
                Elmah.ErrorSignal.FromCurrentContext().Raise(e);
            }

            if (success)
            {
                Response.Write("Success");
            }
            else
            {
                if (msg == null) msg = "Failed to send email";
                Response.Write(msg);
            }

            return null;
        }