1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

ASP server - cant get emails to send from web page

Discussion in 'C#' started by gordano, May 5, 2011.

  1. #1
    Any advice please?

    The script below is not working. Have been going round in circles. Not sure why I need the schemas.microsoft urls but these were advised by the hosting company (who are not very helpful).
    SEMrush
    The error message I get is ... Microsoft VBScript runtime error '800a01a8'

    Object required: ''


    Any help greatly appreciated

    Thanks

    Gordano
    <%
    body="<strong>Forgotten password</strong><br><br>Your registered password is <br><br>" & rs("cust_pass") & "<br><br><a href='http://www.mydomain.co.uk'>http://www.mydomain.co.uk</a>"
    subject = "Forgotten password"


    Dim objCDOSYSCon
    Set objCDOSYSMail = Server.CreateObject("CDO.Message")
    Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
    'Out going SMTP server
    objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver ") = "109.203.96.7"
    'SMTP port
    objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport ") = 25
    objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing ") = 2
    'Timeout
    objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout ") = 60
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="service@mydomain.co.uk"


    objCDOSYSCon.Fields.Update
    Set objCDOSYSMail.Configuration = objCDOSYSCon

    'Who the e-mail is from
    objCDOSYSMail.From = "service@mydomain.co.uk"

    'Who the e-mail is sent to

    ' objCDOSYSMail.To = rs("cust_email")
    objCDOSYSMail.To = "info@mydomain.co.uk"

    'The subject of the e-mail
    objCDOSYSMail.Subject = subject

    'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)

    objCDOSYSMail.HTMLBody = body
    objCDOSYSMail.Send
    Set objCDOSYSMail = Nothing
    Set objCDOSYSCon = Nothing

    end if
    end if
    con.close
    set con=nothing
    %>
     
    gordano, May 5, 2011 IP
    SEMrush
  2. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    ObjSendMail.Configuration should be replaced with objCDOSYSCon
    also you don't declare objCDOSYSMail:
    Dim objCDOSYSMail
     
    camjohnson95, May 16, 2011 IP
  3. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Here is an example of sendmail function that works:
    
        Sub SendMail(subject, msgto, msgbody)
                Dim myMail = Server.CreateObject("CDO.Message")
    
                myMail.Subject = subject
                myMail.From = "you@yourdomain.com"
                myMail.To = msgto
                myMail.HTMLBody = msgbody
    
                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") = "mail.yourdomain.com"
                'Server port
                myMail.Configuration.Fields.Item _
            ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    
                myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
                myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "you@yourdomain.com"
                myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"
                myMail.Configuration.Fields.Update()
    
                myMail.Send()
    
                myMail = Nothing
        End Function
    
    Code (markup):
    I adapted this quickly from asp.net, so it hasn't been tested.
     
    camjohnson95, May 16, 2011 IP