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("C DO.Message")
Set iconf = CreateObject("C DO.Configuratio n")
Set flds = iconf.Fields
' send one copy with SMTP server (with autentication)
schema = "http://schemas.microso ft.com/cdo/configuration/"
flds.Item(schem a & "sendusing" ) = cdoSendUsingPor t
flds.Item(schem a & "smtpserver ") = "mail2.mycompan y.com"
flds.Item(schem a & "smtpserverport ") = 25
flds.Item(schem a & "smtpauthentica te") = cdoBasic
flds.Item(schem a & "senduserna me") = "address@mycomp any.com"
flds.Item(schem a & "sendpasswo rd") = "123abc456"
flds.Item(schem a & "smtpusessl ") = 1
flds.Update
With imsg
..To = "evancater@juno .com"
..From = "Sender <address@mycomp any.com>"
..Subject = "Test send"
..HTMLBody = "Test"
..Sender = "Sender"
..Organization = "My Company"
'.ReplyTo = "address@mycomp any.com"
Set .Configuration = iconf
..Send
End With
Set iconf = Nothing
Set imsg = Nothing
Set flds = Nothing
End Sub
-----------------------------------------------------------------------------------------
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("C DO.Message")
Set iconf = CreateObject("C DO.Configuratio n")
Set flds = iconf.Fields
' send one copy with SMTP server (with autentication)
schema = "http://schemas.microso ft.com/cdo/configuration/"
flds.Item(schem a & "sendusing" ) = cdoSendUsingPor t
flds.Item(schem a & "smtpserver ") = "mail2.mycompan y.com"
flds.Item(schem a & "smtpserverport ") = 25
flds.Item(schem a & "smtpauthentica te") = cdoBasic
flds.Item(schem a & "senduserna me") = "address@mycomp any.com"
flds.Item(schem a & "sendpasswo rd") = "123abc456"
flds.Item(schem a & "smtpusessl ") = 1
flds.Update
With imsg
..To = "evancater@juno .com"
..From = "Sender <address@mycomp any.com>"
..Subject = "Test send"
..HTMLBody = "Test"
..Sender = "Sender"
..Organization = "My Company"
'.ReplyTo = "address@mycomp any.com"
Set .Configuration = iconf
..Send
End With
Set iconf = Nothing
Set imsg = Nothing
Set flds = Nothing
End Sub
-----------------------------------------------------------------------------------------
Comment