We help IT Professionals succeed at work.
Get Started

Send email error

Last Modified: 2013-11-19
I'm using this code to send and email from a contact form on my page that you can find on the link below. I'm getting this error message:

CDO.Message.1 error '80040213'
The transport failed to connect to the server.

It points to the .Send line of code. What can be the problem? The configuration data of my email account?


		Const cdoSendUsingMethod        = _
		Const cdoSendUsingPort          = 2
		Const cdoSMTPServer             = _
		Const cdoSMTPServerPort         = _
		Const cdoSMTPConnectionTimeout  = _
		Const cdoSMTPAuthenticate       = _
		Const cdoBasic                  = 1
		Const cdoSendUserName           = _
		Const cdoSendPassword           = _
		Dim objConfig  ' As CDO.Configuration
		Dim objMessage ' As CDO.Message
		Dim Fields     ' As ADODB.Fields
		Dim FirstName, Email, Message
		FirstName = Request.Form("nome")
		Email = Request.Form("email")
		Message = Request.Form("mensagem")
		' Get a handle on the config object and it's fields
		Set objConfig = Server.CreateObject("CDO.Configuration")
		Set Fields = objConfig.Fields
		' Set config fields we care about
		With Fields
			.Item(cdoSendUsingMethod)       = cdoSendUsingPort
			.Item(cdoSMTPServer)            = "mail.mydomain.pt"
			.Item(cdoSMTPServerPort)        = 25
			.Item(cdoSMTPConnectionTimeout) = 10
			.Item(cdoSMTPAuthenticate)      = cdoBasic
			.Item(cdoSendUserName)          = "username"
			.Item(cdoSendPassword)          = "password"
		End With
		Set objMessage = Server.CreateObject("CDO.Message")
		Set objMessage.Configuration = objConfig
		With objMessage
			.To       = "myname@mydomain.pt"
			.From     = "rtest@aeiou.pt"
			.Subject  = "Teste enviado em "  & Now() 
			.TextBody = "Mensagem enviada em " & Now() & vbCrLf & "Nome: " & FirstName & vbCrLf & "Email: " & Email & vbCrLf & "Messagem: " & Message
		End With
		Set Fields = Nothing
		Set objMessage = Nothing
		Set objConfig = Nothing

Open in new window

Watch Question
IT Pro/Developer
Top Expert 2008
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE