Sending mail using Timer control in Global.asax

  • Thread starter Thread starter Manoj
  • Start date Start date
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.
 
Back
Top