Sending mail using Timer control in Global.asax


M

Manoj

Hi Everyone,

System.timers.timer control is triggering every minute and it is
updating the application variable. But i am not able to send a mail when it
triggers.

please see the code below (Global.asax):

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim aTimer As New System.Timers.Timer
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
aTimer.Interval = 360000
aTimer.Enabled = True
GC.KeepAlive(aTimer)
Application.Lock()
Application("TimeStamp") = DateTime.Now.ToString()
Application.UnLock()
End Sub

Private Sub OnTimedEvent(ByVal source As Object, ByVal e As
Timers.ElapsedEventArgs)
Dim tm As New Tmail
Application.Lock()
Application("TimeStamp") = DateTime.Now.ToString()
tm.sendmail()
Application.UnLock()
End Sub


Please help me in this regard.
Thanks,
Manoj.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top