Jump to content

Any VB scripters here?


RobK
 Share

Recommended Posts

I have a vbs script that uses CDO to send an email. It is used to send reports for a bunch of robocopy jobs that run overnight. The problem is that if several jobs finish at the same time some of the emails do not get sent.

Does anyone know why this happens? I suspect it's to do with several instances of the script trying to access the CDO dll at the same time, but I don't know how to get around it. confused.gif

Link to comment
Share on other sites

Here's the relevant portion of the script:

<font class="small">Code:</font><hr /><pre>

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "[email protected]"

objEmail.To = "[email protected]"

objEmail.Subject = "replication errors"

objEmail.Textbody = "The replication service encountered the following error(s):" & vbCRLF & vbCRLF &"Robocopy result code: " &return & vbCRLF & vbCRLF &strroboerr & vbCRLF & "Please check the log file."

objEmail.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

objEmail.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _

"mail"

objEmail.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objEmail.Configuration.Fields.Update

objEmail.AddAttachment errlogfile

objEmail.Send

End Sub</pre><hr />

Multiple instances of this script are called by a master script so it is running up to 40 or so copies at the same time. I end up losing about 20% of the report emails.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...