Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

ASP CDO Error

Options
  • 18-07-2005 4:54pm
    #1
    Registered Users Posts: 180 ✭✭


    Hi all,

    I'm having a bit of a problem with sending mail in asp. Now I am extremely new to ASP, everything that I have done has been in Java servlets or PHP so I may be missing something completely obvious.

    The script worked perfectly using CDONTS but my hosting provider upgraded and CDONTS is no more so I had to change the script to CDOSYS.

    When the script runs I get the error message

    error '8004020f'

    /admin/mail_contact.asp, line 47

    here is the script in full

    [php]

    <!--#include file="db_open.asp"-->
    <html>
    <head>
    <title>Processing...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>

    <%
    'mailshot script rewritten to use CDOSYS

    Dim MessageBody
    MessageBody = Replace(Request.Form("body"), "'", "''")
    ' MessageBody = Replace(MessageBody,"\n","<br>")

    Dim sSQL
    sSQL = "SELECT * FROM Contacts WHERE Subscribed = TRUE"

    Dim objRS : Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.CursorLocation = 3 ' adUseClient
    objRS.Open sSQL, oConn

    Const cdoSendUsingPort = 2

    'loop to send the message to each person on the contact list
    do while not objRS.EOF

    Dim iMsg : Set iMsg = CreateObject("CDO.Message")
    Dim iConf : Set iConf = CreateObject("CDO.Configuration")

    Dim flds : Set flds = iConf.Fields
    With flds
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.hosting365.ie"
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    .Update
    End With

    With iMsg
    Set .Configuration = iConf
    .From = "info@gallivanireland.com"
    .To = objRS("Email")
    .Subject = Request.Form("subject")
    .TextBody = MessageBody
    .Send
    End With

    Set iMsg = Nothing
    Set iConf = Nothing

    objRS.MoveNext

    loop

    %>
    <!--#include file="db_close.asp"-->
    <!--#include file="footer.htm"-->
    <%

    'redirect to contact list page
    Response.Redirect("list_contact.asp")

    %>
    </body>
    </html>

    [/php]

    I think it is something to do with the recipients address but I can'te really work out what.

    Any ideas?

    All help/comments is greatly appreciated.


Comments

  • Moderators, Politics Moderators Posts: 39,776 Mod ✭✭✭✭Seth Brundle


    run a check to ensure outgoing emails addys are valid -->
    http://www.aspfaq.com/show.asp?id=2238


  • Registered Users Posts: 180 ✭✭marcphisto


    I have done this, for some reason all the emails are showing up as invalid. Now I'm really bloody confused as the emails are valid. :confused:

    It was working perfectly with CDONTS and now it doesn't work at all!!!! :mad:

    I wish I could just port the whole lot to php and have done with it but that just isn't viable.

    I'm not quite sure what I can do from here. If anyone has any ideas at all I would be most greatful


  • Moderators, Politics Moderators Posts: 39,776 Mod ✭✭✭✭Seth Brundle


    Im kind of stumped.
    Ask hosting365 if the smtp server correct (mail.hosting365.ie) or should it be mail.gallivanireland.com

    also just try this...
    <%@ LANGUAGE="VBScript" %>
    <% 
       Dim smtpServer, fromAddr, replyTo, recipient, subject, body
       smtpServer = "mail.gallivanireland.com"
       fromAddr   = "info@gallivanireland.com"
       replyTo = "info@gallivanireland.com"
       recipient = "testmail@gallivanireland.com"
       subject = "test mail"
       body = "this is a test"
    
      Dim cdoMessage, cdoConfig
    
       set cdoMessage = Server.CreateObject("CDO.Message")
       set cdoConfig = Server.CreateObject("CDO.Configuration")
       cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
       cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServer
       cdoConfig.Fields.Update
       set cdoMessage.Configuration = cdoConfig
       cdoMessage.From =  fromAddr
       cdoMessage.ReplyTo = replyTo
       cdoMessage.To = recipient
       cdoMessage.Subject = subject
       cdoMessage.HtmlBody = body
       on error resume next
       cdoMessage.Send
    
       set cdoMessage = Nothing
       set cdoConfig = Nothing
    %> message sent!
    
    This works fine on my site using kbannon.com instead of all instances of gallivanireland.com


  • Registered Users Posts: 180 ✭✭marcphisto


    Thanks peeps but i just rewrote the bastard in php.

    It really pissed me off using the same filter in php as i did in asp for validating email addresses, all show up as invalid in asp, all bar one are valid in php!

    Go figure....

    (as he mumbles about bloody microsoft and their ways and means of frustrating him)


Advertisement