SMTP Hanging during execution
I've used the following email code quite a bit, usually with no problems. The latest program parses a file, and sends the results via email. Problem is, every few runs, the program hangs during the email routine. I believe it gets stuck at the .sendEmail line. No errors, doesn't crash, just hangs up. Usually takes about 20 seconds to attach the file and send the email, I've let it go a few times that it hung up and it stayed stuck for over 5 minutes before I killed it. Am I missing something in this code? As I said, I use this routine alot, just not with a file this large, sometimes it works, sometimes it sticks. grrrr
VB Code:
'send the email
With SMTP
.Server = "serverIPaddress"
.Username = ""
.Password = ""
.MailFrom = "fromName"
.SendTo = "toName" 'bill
.CC = "ccName" 'chris
.BCC = "bccName" 'me
.MessageSubject = strSubject
.MessageText = strBody
.Attachments.Add (mailFile)
lblMain.Caption = lblMain.Caption & " Sending email..." & vbCrLf
Me.Refresh
.sendEmail
.Attachments.Remove (1) 'remove attachment so it doesnt mail again on second pass through
End With
Thanks in advance.