Hi All,
I am currently trying to use CDO to send email messages as part of a program.
The code itself has come from here http://www.rondebruin.nl/cdo.htm and this is the actual code I am using (where ServerName is actually the name of the server I am using, and the To filed is a valid email address);
The problem I am having is that it will intermittingly error on the .Send line and give me a "transport failed to connect to the server" error message, none of the values in any of the fields change, it just fails more often than not. I have asked some colleagues to try this aswell, and they get the same result. Also while it is failing for me, it will work for somebody else & vice versa - frustrating as hell
I have tried out the suggestions outlined on the link provided above, aswell as other suggestions via google (ensuring the SMTP client is installed on the machine, adding the Microsoft CDO object reference, clearing the CDO Message's Configuration fields) all to no avail.
Does anybody else have any suggestions as to a way around this before I bite the bullet and have to use email client specific code?
I am currently trying to use CDO to send email messages as part of a program.
The code itself has come from here http://www.rondebruin.nl/cdo.htm and this is the actual code I am using (where ServerName is actually the name of the server I am using, and the To filed is a valid email address);
Code:
Sub test()
Dim iMsg As Object
Dim iConf As Object
UserId = Environ("USERNAME")
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="ServerName"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
With iMsg
Set .Configuration = iConf
.To = "tanny81@xyz.com"
.CC = ""
.BCC = ""
.FROM = """Me"" <tanny81@xyz.com>"
.Subject = "***TEST*** " & UserId
.TextBody = ""
.Send
End With
End Sub
The problem I am having is that it will intermittingly error on the .Send line and give me a "transport failed to connect to the server" error message, none of the values in any of the fields change, it just fails more often than not. I have asked some colleagues to try this aswell, and they get the same result. Also while it is failing for me, it will work for somebody else & vice versa - frustrating as hell
I have tried out the suggestions outlined on the link provided above, aswell as other suggestions via google (ensuring the SMTP client is installed on the machine, adding the Microsoft CDO object reference, clearing the CDO Message's Configuration fields) all to no avail.
Does anybody else have any suggestions as to a way around this before I bite the bullet and have to use email client specific code?