hi
u can use window service to create a job to execute sql query.
From web page u get the details(date,time,addresses,msg) from user and store in the database.then u create window service to execute the service every 10 secs or ur own specification.
Protected Overrides Sub OnStart(ByVal args() As String)
Try
t = New Timer(5000) '----->every 5 secs
AddHandler t.Elapsed, AddressOf TimerFired
With t
.AutoReset = True
.Enabled = True
.Start()
End With
' MsgBox("start")
Catch obug As Exception
LogEvent(obug.Message)
Throw obug
End Try
End Sub
Protected Overrides Sub OnStop()
Try
log.WriteEntry("Service Stopping", EventLogEntryType.Information)
t.Stop()
t.Dispose()
MsgBox("stop")
Catch obug As Exception
LogEvent(obug.Message)
End Try
End Sub
Private Sub TimerFired(ByVal sender As Object, ByVal e As ElapsedEventArgs)
Working()
End Sub
Private Sub Working()
Dim con As SqlConnection
con = New SqlConnection("Data Source=(local)\nnnnnn;Initial Catalog=JobScheduler;User ID=jjjjjj;Password=jjjjjjjj")
Dim query1 As String
query1 = "Exec [dbo].[GetJobsToRun]"
con.Open()
Dim cmd1 As SqlCommand = New SqlCommand(query1, con)
Dim da1 As New System.Data.SqlClient.SqlDataAdapter(cmd1)
cmd1.ExecuteNonQuery()
con.Close()
End Sub
the above code for window service to execute store procedure([dbo].[GetJobsToRun]) .this sp execute every 5 secs.in that sp u have pass all detail like from,to,msg.before u get the details u have to check time and date(with current data and time).in getjobstorun sp u use select query to get details from table.
u can search for how to send mail from sql server.