public void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { DateTime current = DateTime.Now; //Setting the time to 7PM if ((current.Hour == 7 && current.Minute == 30 && current.Second == 00) || (current.Hour < 00 && current.Minute == 0 && current.Second == 0)) { //MessageBox.Show("Reports have been generated.", "Check Notifications", MessageBoxButtons.OK, MessageBoxIcon.Information); file = Utilities3.generatePDF(); //Generates the pdf at 7PM (Or between 7PM and 12Midnight) and saves it in local computer. Utilities3.sendEmail(file); //Sends the file to a given location (Location is specified at sendEmail() method. //file is a String where it comprises of the location (Address) where the generated PDF is located. You can change it in generatePDF() method. //check out sendEmail(String file) for more information. try { //Thread managements. Have doubts on this. UpdateMessageBox upd = UpdateTheMessageBox; Invoke(upd); } catch (Exception ex) { //MessageBox.Show(ex.ToString()); } } }
void UpdateTheMessageBox(String str) { MessageBox.Show("Reports are generated for the day!"); MessageBox.Show("Reports are generated for the day22222!"); file = Utilities3.generatePDF(); Utilities3.sendEmail(file); showNotification(); }