Tuesday, November 5, 2013

Sending email using CDOSYS in Classi ASP | The transport failed to connect to the server."

CDO.Message - "The transport failed to connect to the server." | CDO.Message.1 error '80040213' | ASP Sending e-mail with CDOSYS

Hello friends, today we learn new thing which is related to mail sending object in Classic ASP. In Classic ASP there are a CDOSYS, built-in component in Classis ASP. This component is used to send e-mails with ASP.

How to create CDOSYS object?
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."
myMail.Send
set myMail=nothing
%>

How to Send a text e-mail with Bcc and CC fields:
Simply Add following code in Above code myMail.Bcc="someoneelse@somedomain.com" myMail.Cc="someoneelse2@somedomain.com"

Some misc code:
Sending an HTML e-mail that sends a webpage from a website:
myMail.CreateMHTMLBody "http://www.w3schools.com/asp/"
Sending an HTML e-mail that sends a webpage from a file on your computer:
myMail.CreateMHTMLBody "http://www.url.com/test.asp/"

Sending a text e-mail with an Attachment:
myMail.AddAttachment "c:\mydocuments\test.txt"

Sending a text e-mail using a remote server:
<% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.TextBody="This is a message." myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 'Name or IP of remote SMTP server myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.server.com" 'Server port myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 myMail.Configuration.Fields.Update myMail.Send set myMail=nothing %>

CDO.Message.1 The transport failed to connect to the server ?

If you got such type of error check out following points:
This is a network related error. Application cannot connect to the mail server (cdoSMTPServer)

  • Is a valid SMTP Server?
  • Be sure the server System.Web.Mail is executing on can connect to the mail server. May be firewalls or proxy servers can get in the way.
  • Specifying the value via IP address. Poor DNS resolution can sometimes hinder name lookups.
  • Make sure the that the mail server is running at port 25.
  • If you did not specify a SmtpMail.SmtpServer property, or if SmtpMail.SmtpServer points to "localhost" (or the equivalent), be sure the SMTP Service is running on port 25.
  • For testing purposes change the MailMessage.From and MailMessage.To properties to an address that exists on SmtpMail.SmtpServer. Some times this exception is thrown, when it really is a relay issue.

No comments:

Post a Comment