Time Ticker when sending email

Add a Timer and a Label


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick 
        If Label1.ForeColor.Equals(Color.Red) Then 
            Label1.ForeColor = Color.Yellow 
        Else 
            Label1.ForeColor = Color.Red 
        End If 

End Sub 

Then under your send button :


'In your Timer properties window set Enabled to False and Interval to 250 

Me.Label1.Text = "Sending Mail" 
  Timer1.Start() 
            Timer1.Enabled = True 

       Dim oMsg As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage 

        oMsg.From = "me@onling.com" 
        oMsg.To = "whoever@yahoo.com" 

        oMsg.Subject = "Test Sending Mail" 
        oMsg.Body = RichTextBox1.Text.ToString 
        Dim oAttch As MailAttachment = New MailAttachment("C:\Backup.zip") 
        oMsg.Attachments.Add(oAttch) 
        SmtpMail.Send(oMsg) 
         
Dim msg As String 
Dim title As String 
Dim style As MsgBoxStyle 
Dim response As MsgBoxResult 
msg = "Your Mail Has Been Sent" 
style = MsgBoxStyle.OKOnly 
title = "Mail Sent Conformation" 
response = MsgBox(msg, style, title) 
If response = MsgBoxResult.OKOnly Then 
   Me.Label1.Text = " " 
 Timer1.Stop() 
            Timer1.Enabled = False 
Else 
    
End If