0

I have a Windows.Form Timer that triggers an event every x minutes(5 minutes for example). Basically when that event is triggered, it sends an email out. I used the SMTPClient.SendAsync(); but it does not send the email out successfully. I tried debugging it but there are no errors whatsoever. The code executes fine when I step over that specific line during debug mode.

The SMTPClient.Send(mail); is working however. But I don't want that for my program since it stops the thread until it's finished executing.

This did not happen when I was using System.Timers.Timer. The SendAsync function was working fine before I switched to the Windows.Form Timer. I was able to receive the emails so it can't be the mail settings such as the port,server,credentials, etc.

Is SendAsync not compatible with an event that is triggered by a Windows.Form Timer? Because it was working when I used System.Timers.Timer

aresz
  • 2,589
  • 6
  • 34
  • 51
  • 1
    Why you can't still use System.Timers.Timer? – pinckerman Sep 02 '13 at 17:42
  • I switch to Windows.Form Timer so that I have control on the UI(such as clearing a textbox from the event). I can't do that when using System.Timers.Timer. The email that I'm sending contains whatever is in the textbox. After the email is sent, I'll clear the textbox for new logs. Rinse and repeat – aresz Sep 02 '13 at 18:13
  • Add some code, maybe you're doing something wrong. – pinckerman Sep 02 '13 at 18:47
  • I've found this on MSDN: "The Windows Forms Timer component is single-threaded, and is limited to an accuracy of 55 milliseconds. If you require a multithreaded timer with greater accuracy, use the Timer class in the System.Timers namespace." Could be this that doesn't allow you to use SendAsync? – pinckerman Sep 02 '13 at 18:56

0 Answers0