We help IT Professionals succeed at work.
Get Started

Send email error

331 Views
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?

jppinto

http://www.caraibas.info/luademel/contacto.asp
<%
		Const cdoSendUsingMethod        = _
			"http://schemas.microsoft.com/cdo/configuration/sendusing"
		Const cdoSendUsingPort          = 2
		Const cdoSMTPServer             = _
			"http://schemas.microsoft.com/cdo/configuration/smtpserver"
		Const cdoSMTPServerPort         = _
			"http://schemas.microsoft.com/cdo/configuration/smtpserverport"
		Const cdoSMTPConnectionTimeout  = _
			"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
		Const cdoSMTPAuthenticate       = _
			"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
		Const cdoBasic                  = 1
		Const cdoSendUserName           = _
			"http://schemas.microsoft.com/cdo/configuration/sendusername"
		Const cdoSendPassword           = _
			"http://schemas.microsoft.com/cdo/configuration/sendpassword"
		
		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"
		
			.Update
		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
			.Send
		End With
		
		Set Fields = Nothing
		Set objMessage = Nothing
		Set objConfig = Nothing
		%>

Open in new window

Comment
Watch Question
IT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008
Commented:
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