problems using CDO winhost server

Discussion in 'Email' started by marconellino, Feb 2, 2011.

  1. Hi,
    i want to use a simple email form (asp) using cdo.
    I copied and applied my details on the page but there is an error.
    This is the code:
    set objMessage = createobject("cdo.message")
    set objConfig = createobject("cdo.configuration")
    Set Flds = objConfig.Fields

    Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.costaricarentvillas.com"

    ' ' Passing SMTP authentication
    Flds.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
    Flds.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="[email protected]"
    Flds.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="mypassword..."

    Flds.update
    Set objMessage.Configuration = objConfig
    objMessage.To = "[email protected]"
    objMessage.From = "[email protected]"
    objMessage.Subject = "New Task"
    objMessage.fields.update
    objMessage.HTMLBody = "This is a test sent from CDO using smtp authentication."
    objMessage.Send

    Of course i used my postamaster password (hidden now for security)


    The error is:
    CDO.Message.1 error '80040213'
    The transport failed to connect to the server.
    /send.asp, line 27



    Pls let me know
    Bye
    Marco
     
  2. Ray

    Ray

    Were is this ASP script residing on? Has it been uploaded to our web server and are you able to send email through your Outlook using mail.costaricarentvillas.com?
     
  3. I am having the same issue.

    Using CDOSYS and an asp mailer that worked on my own servers.

    Now it appears that the form is sent but does not arrive and the re direct part fails. Error 500.

    This is the old code.

    <title>Information Request from Advanced Web Databases, Inc. Corporate Website</title>
    <%
    Dim fromEmail
    Dim toEmail
    Dim subject
    Dim smtpServer
    Dim redirectUrl

    fromEmail = Request.Form ("email")
    toEmail = "[email protected]"
    subject = "Information Request from Advanced Web Databases, Inc. Corporate Website"
    smtpServer = "mail.advancedwebdb.com"
    redirectUrl = "thankyou.asp"


    For Field = 1 to Request.Form.Count - 1
    FieldName = Replace(Request.Form.Key(Field),"_"," ")
    FieldValue = Request.Form.Item(Field)
    Body = Body & FieldName & ": " & FieldValue & VbCrLf
    Next
    'Dimension variables
    Dim objCDOSYSCon
    'Create the e-mail server object
    Set objCDOSYSMail = Server.CreateObject("CDO.Message")
    Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
    'Set and update fields properties
    With objCDOSYSCon
    'Outgoing SMTP server
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServer
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    'CDO Port
    .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    'Timeout
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    .Fields.Update
    End With
    'Update the CDOSYS Configuration
    Set objCDOSYSMail.Configuration = objCDOSYSCon
    'Set and update email properties
    With objCDOSYSMail
    '0=Low, 1=Normal, 2=High
    .Fields("urn:schemas:httpmail:importance").Value = 1
    'Who the e-mail is from
    .From = fromEmail 'Request.Form("email_address")
    'Who the e-mail is sent to
    .To = toEmail '"[email protected]"
    'Who the e-mail is CC'd to
    .Cc = fromEmail
    'The subject of the e-mail
    .Subject = subject 'Request.Form("email_subject")
    'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)
    .TextBody = Body
    .Fields.Update
    'Send the e-mail
    .Send
    End With
    'Close the server mail object
    Set objCDOSYSMail = Nothing
    Set objCDOSYSCon = Nothing


    'Rederect after sending email
    Response.Redirect redirectUrl 'Request.Form("redirect_to")
    %>

    I know I need to add authentication and I was going to do that but was not sure where it would go ??
     
  4. Ray

    Ray

    Last edited by a moderator: Oct 14, 2015
  5. Yes I did and have fixed it.

    Added dim username and dim password after dim redirecturl.

    The hard coded both of them below the redirect url.
     

Share This Page