ASP Sending e-mail with CDO

  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 07, 2004
  • Posts: 2390
  • Loc: Edinburgh, Scotland
  • Status: Offline

Post February 22nd, 2005, 3:58 pm

You don't have to join it! It's someone who has posted the same problem as you. I'm merely suggesting that you follow the advice given to this guy. I program in ASP at work, and as such, all my ASP files/books are there. Hence, I can't look up the error code to find out what the cause may be.

As I say, check google. From what I've seen, you may have to configure your server's CDO to take into account your SMTP server. I have personally never had to do that, as my work's version was previously set-up.
Why do geeks get Halloween and Christmas confused?
Because 31 Oct == 25 Dec
www.darren-king.co.uk
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post February 22nd, 2005, 3:58 pm

  • pritesh_a
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 15, 2004
  • Posts: 158
  • Loc: South London/UK
  • Status: Offline

Post February 22nd, 2005, 4:04 pm

ok thanks mate.
i cant actually view that topic on that website, it wont help me.

iv tried typring in the error message text:
Error Type CDO.Message.1 (0x80040220)
into google, no joy

do u wana see all my code so far?

thanks for all the help
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 07, 2004
  • Posts: 2390
  • Loc: Edinburgh, Scotland
  • Status: Offline

Post February 22nd, 2005, 4:08 pm

Yeah, post the full code. I'm turning in for the nite soon, but I'll have a look at it in the morning when I get to work.
Why do geeks get Halloween and Christmas confused?
Because 31 Oct == 25 Dec
www.darren-king.co.uk
  • pritesh_a
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 15, 2004
  • Posts: 158
  • Loc: South London/UK
  • Status: Offline

Post February 22nd, 2005, 4:12 pm

two files called
email.asp
<html>
<head>

</head>
<body>
<form action="sendemail.asp" method="post">
<p>To:</p>
<input type="text" name="to_field" />
<p>Message:</p>
<textarea name="message_field" rows="5"></textarea>
<input type="submit" value="Send Email" />
</form>
</body>
</html>

file 2
sendemail.asp
<%
dim to_field, message
to_field = Request.Form("to_field")
message = Request.Form("message_field")
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="pri.amin5@hotmail.com"
myMail.To= to_field
myMail.HTMLBody = message
myMail.Send
%>

the above is ALL the code from the 2files.

any help is grateful
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 07, 2004
  • Posts: 2390
  • Loc: Edinburgh, Scotland
  • Status: Offline

Post February 23rd, 2005, 1:22 am

Using the above code, I was able to send an email to myself, apparantly from "pri.amin5@hotmail.com" with "Sending email with CDO" as the subject.
Hence, my CDO configuration is working. You'll need to figure out how to configure CDO to point to your SMTP server (so it knows where to send the email).

Here is the example that was contained in the link I had previously posted. I don't know if this works, as my CDO is properly configured and I don't want to mess about with it.
Code: [ Select ]
'Dimension variables
Dim objCDOSYSCon

'Create the e-mail server object
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") = "mail.example.co.uk"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update

'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = "orders@example.co.uk"
objCDOSYSMail.TO = "Email Address"
objCDOSYSMail.BCC = "any@example.co.uk"
objCDOSYSMail.Subject = "Subject goes here"
objCDOSYSMail.HTMLBody = "<html><p>Html formatted message goes here</p></html>"
objCDOSYSMail.Send

'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
  1. 'Dimension variables
  2. Dim objCDOSYSCon
  3. 'Create the e-mail server object
  4. Set objCDOSYSMail = Server.CreateObject("CDO.Message")
  5. Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
  6. 'Out going SMTP server
  7. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.example.co.uk"
  8. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  9. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  10. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
  11. objCDOSYSCon.Fields.Update
  12. 'Update the CDOSYS Configuration
  13. Set objCDOSYSMail.Configuration = objCDOSYSCon
  14. objCDOSYSMail.From = "orders@example.co.uk"
  15. objCDOSYSMail.TO = "Email Address"
  16. objCDOSYSMail.BCC = "any@example.co.uk"
  17. objCDOSYSMail.Subject = "Subject goes here"
  18. objCDOSYSMail.HTMLBody = "<html><p>Html formatted message goes here</p></html>"
  19. objCDOSYSMail.Send
  20. 'Close the server mail object
  21. Set objCDOSYSMail = Nothing
  22. Set objCDOSYSCon = Nothing


Obviously this can be adapted to suit your variable names etc.
Why do geeks get Halloween and Christmas confused?
Because 31 Oct == 25 Dec
www.darren-king.co.uk
  • pritesh_a
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 15, 2004
  • Posts: 158
  • Loc: South London/UK
  • Status: Offline

Post February 23rd, 2005, 1:28 am

so i need to configure my CDO?
how do i go about doing that?
where can i see my SMPT settings?

so the email i send from my site, is using the email address pri_amin5@hotmail.com to send the message??
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 07, 2004
  • Posts: 2390
  • Loc: Edinburgh, Scotland
  • Status: Offline

Post February 23rd, 2005, 1:51 am

Using the example above!
see the line "Set objCDOSYSCon = Server.CreateObject("CDO.Configuration")"? That creates a new CDO configuration object. The next block of code in the example sets up the settings for your SMTP server. The configuration object then gets assigned to the CDO Mail message.
Are you running your own mail server? If so, enter the domain name/IP of this in the configuration (in place of "mail.example.co.uk"). If not, your ISP most probably provides you with some SMTP server settings in order for you to send email. If you have Outlook Express (or a similar program) and use this to check your email, your settings will be stored in there. Failing that, ask your ISP what the SMTP server is (usually it's something like "smtp.blueyonder.co.uk").
Why do geeks get Halloween and Christmas confused?
Because 31 Oct == 25 Dec
www.darren-king.co.uk
  • pritesh_a
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 15, 2004
  • Posts: 158
  • Loc: South London/UK
  • Status: Offline

Post February 23rd, 2005, 2:32 am

no i dont think im running my own mail server, i use my hotmail or gmail account!

the code u posted above will be placed in my sencond, sendemail.asp file RIGHT?

do i just need to change
objCDOSYSMail.From = "orders@example.co.uk"

putting in my email address
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 07, 2004
  • Posts: 2390
  • Loc: Edinburgh, Scotland
  • Status: Offline

Post February 23rd, 2005, 2:39 am

You would know if you were running your own mail server. You can't use Hotmail or Gmail is your SMTP server as these are internet based mail services. As I said, find out the address of your ISP's mail server. Who provides your internet connection? BT? Tiscali? Wanadoo? They will have an SMTP server set up sepecifically to handle mail. You will need this address, as you will need this server to actually send your message.

Correct, the code I posted goes in the second file. Once you have found out your SMTP server address, the code will look something like this:
Code: [ Select ]
dim to_field, message
'Create the e-mail server object
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") = "MY_ISP_SMTP_SERVER_ADDRESS"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update

'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = "me@myhost.co.uk" ' the address you want the email to be from
objCDOSYSMail.TO = to_field 'the address the mail is to be sent to
objCDOSYSMail.Subject = "Subject goes here"
objCDOSYSMail.HTMLBody = message
objCDOSYSMail.Send

'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
  1. dim to_field, message
  2. 'Create the e-mail server object
  3. Set objCDOSYSMail = Server.CreateObject("CDO.Message")
  4. Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
  5. 'Out going SMTP server
  6. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "MY_ISP_SMTP_SERVER_ADDRESS"
  7. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  8. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  9. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
  10. objCDOSYSCon.Fields.Update
  11. 'Update the CDOSYS Configuration
  12. Set objCDOSYSMail.Configuration = objCDOSYSCon
  13. objCDOSYSMail.From = "me@myhost.co.uk" ' the address you want the email to be from
  14. objCDOSYSMail.TO = to_field 'the address the mail is to be sent to
  15. objCDOSYSMail.Subject = "Subject goes here"
  16. objCDOSYSMail.HTMLBody = message
  17. objCDOSYSMail.Send
  18. 'Close the server mail object
  19. Set objCDOSYSMail = Nothing
  20. Set objCDOSYSCon = Nothing
Why do geeks get Halloween and Christmas confused?
Because 31 Oct == 25 Dec
www.darren-king.co.uk
  • pritesh_a
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 15, 2004
  • Posts: 158
  • Loc: South London/UK
  • Status: Offline

Post February 23rd, 2005, 2:44 am

thanls so much mate,
im going to try find out my SMPT address, im using NTL, i should have it writen down somewhere!

i thinh the SMPT is:
smpt.ntlworld.com
sound write?


Would u like a very large email storage space for you all your help? FREE
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 07, 2004
  • Posts: 2390
  • Loc: Edinburgh, Scotland
  • Status: Offline

Post February 23rd, 2005, 2:51 am

That sounds about right.

Give it a try and let me know how it goes.
Why do geeks get Halloween and Christmas confused?
Because 31 Oct == 25 Dec
www.darren-king.co.uk
  • pritesh_a
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 15, 2004
  • Posts: 158
  • Loc: South London/UK
  • Status: Offline

Post February 23rd, 2005, 3:00 am

Right, the two files as follow:
email.asp
<html>
<head>

</head>
<body>
<form action="sendemail1.asp" method="post">
<p>To:</p>
<input type="text" name="to_field" />
<p>Message:</p>
<textarea name="message_field" rows="5"></textarea>
<input type="submit" value="Send Email" />
</form>
</body>
</html>

file2
sendemail1.asp
<%
dim to_field, message
'Create the e-mail server object
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") = "smpt.ntlworld.com"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update

'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = "navin.amin@ntlworld.com" ' the address you want the email to be from
objCDOSYSMail.TO = to_field 'the address the mail is to be sent to
objCDOSYSMail.Subject = "Subject goes here"
objCDOSYSMail.HTMLBody = message
objCDOSYSMail.Send

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

NOT WORKING
ERROR MESSAGE:
The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.

Please try the following:

* Click the Refresh button, or try again later.
* Open the xx.x.xxx.xx home page, and then look for links to the information you want.

HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

Technical Information (for support personnel)

* Error Type:
CDO.Message.1 (0x8004020C)
At least one recipient is required, but none were found.
/email/sendemail1.asp, line 20

* Browser Type:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.7.5) Gecko/20041110 Firefox/1.0

* Page:
POST 49 bytes to /email/sendemail1.asp

* POST Data:
to_field=pri.amin%40gmail.com&message_field=khjkh

* Time:
23 February 2005, 09:56:20

* More information:
Microsoft Support

if i go to Control pannel, then, Admin Tools, open IIS, right click on my Default SMTP Virtual Server
the properties fir IP address are UNASSIGNED,
sould my IP addess be in this section??
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 07, 2004
  • Posts: 2390
  • Loc: Edinburgh, Scotland
  • Status: Offline

Post February 23rd, 2005, 3:08 am

Forgot to get the variables from the FORM:

Code: [ Select ]
dim to_field, message
to_field = Request.Form("to_field")
message = Request.Form("message")

'Create the e-mail server object
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") = "MY_ISP_SMTP_SERVER_ADDRESS"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update

'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = "me@myhost.co.uk" ' the address you want the email to be from
objCDOSYSMail.TO = to_field 'the address the mail is to be sent to
objCDOSYSMail.Subject = "Subject goes here"
objCDOSYSMail.HTMLBody = message
objCDOSYSMail.Send

'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
  1. dim to_field, message
  2. to_field = Request.Form("to_field")
  3. message = Request.Form("message")
  4. 'Create the e-mail server object
  5. Set objCDOSYSMail = Server.CreateObject("CDO.Message")
  6. Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
  7. 'Out going SMTP server
  8. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "MY_ISP_SMTP_SERVER_ADDRESS"
  9. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  10. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  11. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
  12. objCDOSYSCon.Fields.Update
  13. 'Update the CDOSYS Configuration
  14. Set objCDOSYSMail.Configuration = objCDOSYSCon
  15. objCDOSYSMail.From = "me@myhost.co.uk" ' the address you want the email to be from
  16. objCDOSYSMail.TO = to_field 'the address the mail is to be sent to
  17. objCDOSYSMail.Subject = "Subject goes here"
  18. objCDOSYSMail.HTMLBody = message
  19. objCDOSYSMail.Send
  20. 'Close the server mail object
  21. Set objCDOSYSMail = Nothing
  22. Set objCDOSYSCon = Nothing
Why do geeks get Halloween and Christmas confused?
Because 31 Oct == 25 Dec
www.darren-king.co.uk
  • pritesh_a
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 15, 2004
  • Posts: 158
  • Loc: South London/UK
  • Status: Offline

Post February 23rd, 2005, 3:13 am

so i dont need a third page for the sent or fail confirmation??i.e. sent.asp

still not work!!!!!!
do i need to create the subject box in the first form???

DO u want a gmail account???
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 07, 2004
  • Posts: 2390
  • Loc: Edinburgh, Scotland
  • Status: Offline

Post February 23rd, 2005, 3:23 am

You don't need a third page. You don't need a subject box either. Post the error you are getting.

Thanks, but no thanks :D I've already got more emaila ccounts than I can keep track of :D
Why do geeks get Halloween and Christmas confused?
Because 31 Oct == 25 Dec
www.darren-king.co.uk
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post February 23rd, 2005, 3:23 am

Post Information

  • Total Posts in this topic: 52 posts
  • Users browsing this forum: No registered users and 227 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.