I have a thread program with VB.net which is generating reports and sending emails in async way after it.
It is executed by batch file.
The problem I am facing is, .bat is closed when not all smtp server sendasync are completed. However, email could be received when I run in web application.
Therefore, no email could be received. How can I waiting for all SMTP SendAsync tasks before process end.
Private Sub Process()
reportGenerating()
fileZip()
emailSend()
End Sub
Private Sub emailSend()
'looping something and prepare message/attachements
For xxxxxxx
AddHandler client.SendCompleted, AddressOf SendMailCompletedCallBack
client.SendAsync(message, id)
Next
End Sub