I'm not entirely sure what I'm doing. But this is what I have so far but I'm not sure how to get it to check a file for the date. As well as a lot of other things.
'Option Strict On
Option Explicit On
Public Class Timer1
Dim aTimer As New System.Timers.Timer()
aTimer.Interval = 86400000
aTimer.Enabled = True
Partial Class EmailAll
Protected Sub EmailReminder()
Dim conn As New SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=EmailReminder;Integrated Security=True")
Dim cmd As New SqlCommand("SELECT Email, FullName, Printer, ReminderID FROM Reminders WHERE Active=1 AND EmailDate<=getdate()", conn)
Dim reader As SqlDataReader
Dim strIDs As String = ""
Dim strIDsFailed As String = ""
Dim MyMail As MailMessage = New MailMessage()
Dim emailbody As String = ""
reader = cmd.ExecuteReader()
If reader.HasRows Then
MyMail = New MailMessage()
MyMail.From = "email@example.com"
MyMail.To = reader("Email")
MyMail.Subject = "Meter Reading Reminder"
MyMail.Body = emailbody & "Dear " & reader("FullName") & ", this is your reminder to report your meter reading for your " & reader("Printer") & _
". You can report it at http://www.hackworthimaging.com/meterreading.asp"
MyMail.BodyEncoding = Encoding.ASCII
MyMail.BodyFormat = MailFormat.Text
MyMail.Priority = MailPriority.Normal
SmtpMail.SmtpServer = "localhost"
strIDs &= "," & reader("ReminderID")
strIDsFailed &= "," & reader("ReminderID")
'You should try looping through this again for all those who failed ("ids")
If Len(strIDs) > 0 Then
If strIDs.Substring(0, 1) = "," Then strIDs.Remove(0, 1)
cmd = New SqlCommand("UPDATE Reminders SET EmailDate=DATEADD(mm, 1, EmailDate) WHERE ReminderID IN (" & strIDs & ")", conn)
'might want to write to a text file all the id's that failed to be sent.
'write to a text file about the date this failed.
Yeah, that wasn't a finished product. I just wasn't sure what comes next. I'm guessing it supposed to call the file that holds the email dates, which I do not have as of yet. What is supposed to be holding that?