Web Wiz - Solar Powered Eco Web Hosting

  New Posts New Posts RSS Feed - Sending Email with CDOSYS
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Sending Email with CDOSYS

 Post Reply Post Reply
Author
 Rating: Topic Rating: 1 Votes, Average 5.00  Topic Search Topic Search  Topic Options Topic Options
NeilHutch View Drop Down
Newbie
Newbie
Avatar

Joined: 28 July 2010
Location: Parkstone
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote NeilHutch Quote  Post ReplyReply Direct Link To This Post Topic: Sending Email with CDOSYS
    Posted: 28 July 2010 at 9:16pm
Hi any server gurus,
I am trying to get an email form setup using CDOSYS and I get this error message:

CDO.Message.1 error '80040213'

The transport failed to connect to the server.

I have a "simple" example that I am testing which fails in the same way that the actual form does.
The code:
<%
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message") 
     
'This section provides the configuration information for the remote SMTP server.
     
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.WebSiteLive.net "
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
     
' If your server requires outgoing authentication uncomment the lines below and use a valid email address and password.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="remove@email"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="password"
     
ObjSendMail.Configuration.Fields.Update
     
'End remote SMTP server configuration section==
     
ObjSendMail.To = "remove@email"
ObjSendMail.Subject = "Website Enquiry "
ObjSendMail.From = "someone@someone.net"
     
' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"
     
ObjSendMail.Send (fails on this line)
     
Set ObjSendMail = Nothing 
%>
I am hoping that I have made an obvious and glaring mistake but to be honest only understand enough to make me dangerous :)

Any help would be appreciated
Neil Hutch



Edited by WebWiz-Bruce - 29 July 2010 at 7:50am
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Poole
Status: Offline
Points: 9556
Answer Answer
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 29 July 2010 at 8:17am
I've removed your email address from your code in your post, so you do not end up with loads of spam from publishing it on a forum.

Looking at the syntax that you have there is looks wrong.

The code below will work with our servers here, you just need to put in your email address and password where indicated:-

<%
'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
   
        ' Specify the authentication mechanism to basic (clear-text) authentication cdoBasic = 1
        .Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
           
        'SMTP Server username
        .Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "you@youremailhere.com"
           
        'SMTP Server password
        .Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YourPasswordHere"
     
   
    'Out going SMTP server
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.websitelive.net"
   
    'SMTP port
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")  = 25
   
    'CDO Port (1=localhost 2=network)
    .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

With objCDOSYSMail
    'Who the e-mail is from
    .From = " <you@youremailhere.com>"

    'Who the e-mail is sent to
    .To = " <to@toemailhere.com>"
   

    'The subject of the e-mail
    .Subject = "Website Enquiry"

    'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)
    .HTMLBody = "this is the body"
    '.TextBody = "this is the body"


    'Send the e-mail
    .Send
End with

'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
%>



Edited by WebWiz-Bruce - 26 April 2011 at 11:28am
Back to Top
NeilHutch View Drop Down
Newbie
Newbie
Avatar

Joined: 28 July 2010
Location: Parkstone
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote NeilHutch Quote  Post ReplyReply Direct Link To This Post Posted: 05 August 2010 at 2:49pm
Thank you for that, code works perfectly.
Thumbs Up
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.01
Copyright ©2001-2018 Web Wiz Ltd.


Become a Fan on Facebook Follow us on Twitter Connect with us on LinkedIn Community Forums Web Wiz Blogs Web Wiz News
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Policy

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2019 Web Wiz Ltd. All rights reserved.