|
-
Jul 21st, 2011, 10:08 PM
#1
Thread Starter
New Member
VB6 CDO Email Lockup Bug
I have been using the below VB6 code to send emails every 30 minutes, program running continuously. Code has been very successful when transmitting emails connected to a land based LAN. When sending via a satellite based comms link (where comms speeds are noticeably slower), the SW can lock up in the “.SEND” process. Occurs about once a day. Have to use TaskManager to completely shutdown program before restarting.
Code:
On Error GoTo cAppMsg_SendEmailError
With cdoConf.Fields
.item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = Email.SMTPserver
.item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
If (Email.Username = "") Then
.item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0
Else
.item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Email.Password
.item("http://schemas.microsoft.com/cdo/configuration/sendusername") = Email.Username
End If
.Update
End With
With cdoMsg
Set .Configuration = cdoConf
.To = Email.ToAddress
.from = Email.fromAddress
.Subject = Email.Subject
.TextBody = strBody
.BCC = ""
.CC = ""
.Send
End With
Set cdoMsg = Nothing
Set cdoConf = Nothing
Any suggestions to prevent or exit from the problem?
Thks for yr help.
-
Jul 22nd, 2011, 07:12 AM
#2
Re: VB6 CDO Email Lockup Bug
Aside from your use of magic numbers (all of those Field names have predefined constants, as do many of the setting values) there isn't much to comment on.
The cdoSMTPConnectionTimeout field has been set to 60 seonds. So if it exceeds 60 seconds to connect you ought to be seeing an exception raised. Once connected however a slow connection can probably take... as long as it takes to get the job done.
What kind of answer were you hoping for? I don't see any programming problem here, just an infrastructure problem we can't do anything about.
About all I can think of to suggest is that you have a special case here that might be handled differently. Your existing program could be changed to just queue emails for sending, and a second program could be written to pick up these queued emails and send them at the pace it can manage. For something as slow as every 30 minutes you might just use a some folder as a queue and drop each outbound message into it as a file named based on the timestamp.
The worker program could be a Service or it might just be a Startup folder program or something. It could just look in the pickup folder (queue) for the next message and try to send it via CDO or whatever approach you want. I suppose you can write that as two programs: a monitor program to start and make sure the actual worker doesn't lock up, and a worker to pick up and send stuff.
If the monitor detects the worker has locked up it can kill it, then sleep for a while before starting the worker to try again.
Of course this is all basically what the IIS SMTP Service already does for you. Perhaps you might consider using that as your local mail relay service. CDO can send through that with just a few changes to the configuration parameters.
-
Jul 24th, 2011, 08:36 PM
#3
Thread Starter
New Member
Re: VB6 CDO Email Lockup Bug
Thks you for your reply.
We have a network of these systems installed creating simple text messages to be emailed every 30 mins. All email programs use the same basic set of email settings, all sending to the same server, only in the content of the data messages is there any differences. So don't believe this is the problem.
Regarding your paragraph "About all I can think of to suggest...". We have already designed our software along the basic lines you have suggested.
The main problem appears to be that the timeout function (whether 60 secs or some other period) does not appear to work in all circumstances! If possible I would prefer to be able to fix this problem from within the VB program itself. ie. If the email CDO program does not return then a new procedure would be run to kill it, and then continue on.
Is there some way to do this from within a VB program?
Thks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|