The transport lost its connection to the server

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
cyberic68
Newbie
Posts: 4
Joined: Thu Oct 16, 2014 1:03 pm

The transport lost its connection to the server

Post by cyberic68 » Thu Oct 16, 2014 1:14 pm

Hi,

I'm trying to use this script to sent email and attachment files, but from time to time I getting this error message and it failed to send the email.

CDO.Message.1 :2147220974
The transport lost its connection to the server.
Line 33, Column 8

Here's my script

===================================================================================

VBSTART
'Uses Microsoft CDO Message COM class in Win2k,XP & above. See:
'http://msdn.microsoft.com/library/en-us ... erface.asp
Function SendEmail(toaddr,fromaddr,subject,body,html)
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
'change your mail server on the next line
.Item(sch & "smtpserver") = "mysmtp.server.com"
.update
End With

Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.From = fromaddr
.To = toaddr
.Subject = subject
if html = 1 then
.HTMLBody = "<html><body>Hi Everyone,<br><br>Here is, the daily report<br></body></html>"
else
.TextBody = body
end if
'you can create html body from a web page:
'.CreateHTMLBody "http://blablabla.com/bla.htm"
'you can add attachments:
.AddAttachment "C:\Private\reports\daily_report.txt"
.AddAttachment "C:\Private\reports\daily_report.pdf"
'see URL at top for more options
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing
End Function
VBEND
Let>recipients=[email protected]
VBEval>Date()-1,yesterday
VBEval>SendEmail("%recipients%","[email protected]","%yesterday% Daily Report ","%body%",1),res


===================================================================================

Thanks

Eric

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts