deadseasquirrels
Board Regular
- Joined
- Dec 30, 2004
- Messages
- 232
I've been trying to send emails through an SMTP server in various ways. I've been able to send email using CDO going directly through an SMTP server on my same local network (not requiring a username and password). But now I am trying to send email from my home with the SMTP server I am using that is hosted by some commercial company. I used the code below, which is sponsored by Paul Sadowski:
So this code doesn't work. It says "Transport failed to connect to server" which is pretty general. But the thing is I do use the SMTP server from outlook, so port 25 is not blocked, I'm positive I am using the correct username and password (again, because outlook works). Also I know the SMTP server requires authentication...so I'm not sure what else is wrong. If Mr. Sadowski is on this forum maybe you can reply as well. Anybody have any experience with this?
Code:
Sub sendMailRemote()
'Sending a text email using authentication against a remote SMTP server
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
Dim objMessage As Object
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.Sender = """Me"" <me@my.com>"
objMessage.To = "me@hotmail.com"
objMessage.TextBody = "This is some sample message text.." & vbCrLf & "It was sent using SMTP authentication."
'==This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.myserver.com"
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "deadesasquirrels"
'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "squirrels"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
End Sub
So this code doesn't work. It says "Transport failed to connect to server" which is pretty general. But the thing is I do use the SMTP server from outlook, so port 25 is not blocked, I'm positive I am using the correct username and password (again, because outlook works). Also I know the SMTP server requires authentication...so I'm not sure what else is wrong. If Mr. Sadowski is on this forum maybe you can reply as well. Anybody have any experience with this?