Email not sent in console application

I have made a console application which check backup file on Ftp and then sends a email
In i have written this code and called the method to Send an email:

Dim objTimer As new CustomTimer objTimer.Mode = Timer.ModeMultiple do App.DoEvents 3000 ProSendEmail(CurrentDate) loop

The method to send email is:

[code]EmailSocket = new MailSocket //Mailsocket is SMTPSecureSocket
Dim mail As New EmailMessage
EmailSocket.Address = “mail.server” // your SMTP email server
EmailSocket.Port =123

While 1=1
If EmailSocket.IsConnected Then Exit

mail.FromAddress = “
mail.Subject = "Database backup is missing for Date "
mail.BodyPlainText =“Test email”


The mail is not sent. What am I doing wrong in this?

Thanks in advance

Please run a loop calling app.DoEvents or at least socket.poll to give time to the socket.

The SMTP Secure Socket manages its own connection, so remove the code


While 1=1
If EmailSocket.IsConnected Then Exit
from your method.

In the run event handler you are executing your event loop every 3 seconds and then executing prosendmail which I’m assuming is the name of the second method. Repeatedly running sendmail will cause the SMTPSocket to fail to complete any send, wait until the MailSent event has fired before sending further mail.

This class is what I use in Web Apps to send email from multiple sessions while avoiding these collisions.

I have a console app that sends a status email.
Code similar to the following, placed at the end of the SendEmail method, is necessary to allow the socket time to send the email:

do until socket.Messages.Ubound = -1 socket.Poll loop

Run your main loop more frequently, like 10ms, and send your email from a timer.

I have the same problem.
in the console app I can not send email
socket error 103 happens.
The same code in a windows application works flawlessly.

Using a Timer and using the above mentioned class for multiple email-sending did not work.