I'm trying to send an email from an Access procedure using CDO. I've
been able to do it successfully with three different sending email
addresses, but not with the email address I actually need to use in
production. In that case I get a message saying "The transport failed
to connect to the server." I've tried several different ports. Anybody
have any idea what the problem might be? My code is below.
-----------------------------------------------------------------------------------------
Public Sub SendEmail()
Dim imsg As Message
Dim iconf As Object
Dim flds As Object
Dim schema As String
Set imsg = CreateObject("CDO.Message")
Set iconf = CreateObject("CDO.Configuration")
Set flds = iconf.Fields
' send one copy with SMTP server (with autentication)
schema = "http://schemas.microsoft.com/cdo/configuration/"
flds.Item(schema & "sendusing") = cdoSendUsingPort
flds.Item(schema & "smtpserver") = "mail2.mycompany.com"
flds.Item(schema & "smtpserverport") = 25
flds.Item(schema & "smtpauthenticate") = cdoBasic
flds.Item(schema & "sendusername") = "ad*****@mycompany.com"
flds.Item(schema & "sendpassword") = "123abc456"
flds.Item(schema & "smtpusessl") = 1
flds.Update
With imsg
..To = "ev*******@juno.com"
..From = "Sender <ad*****@mycompany.com>"
..Subject = "Test send"
..HTMLBody = "Test"
..Sender = "Sender"
..Organization = "My Company"
'.ReplyTo = "ad*****@mycompany.com"
Set .Configuration = iconf
..Send
End With
Set iconf = Nothing
Set imsg = Nothing
Set flds = Nothing
End Sub
-----------------------------------------------------------------------------------------