ASP Sending e-mail with CDO

  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

i want to send e-mails from my website! i.e allow users to create and send emails to who ever!

I have the asp code to send the e-mail, but do i need to create the form for this page i.e. in DWMX?

and just put the code in between the HTML code?

code from http://www.w3schools.com/asp/asp_send_email.asp
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.HTMLBody = "<h1>This is a message.</h1>"
myMail.Send
%>

or

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."
myMail.Send
%>

thanks anyone
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

Well, you'll need to post the values to the ASP page that is to send the email:
Code: [ Select ]
<html>
<head>

</head>
<body>
<form action="send_email_page.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>
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <form action="send_email_page.asp" method="post">
  6. <p>To:</p>
  7. <input type="text" name="to_field" />
  8. <p>Message:</p>
  9. <textarea name="message_field" rows="5"></textarea>
  10. <input type="submit" value="Send Email" />
  11. </form>
  12. </body>
  13. </html>


Then, on your processing page:
Code: [ Select ]
<%
  dim to, message
  to = Request.Form("to_field")
  message = Request.Form("message_field")
  Set myMail=CreateObject("CDO.Message")
  myMail.Subject="Sending email with CDO"
  myMail.From="mymail@mydomain.com"
  myMail.To= to
  myMail.HTMLBody = message
  myMail.Send
%>
  1. <%
  2.   dim to, message
  3.   to = Request.Form("to_field")
  4.   message = Request.Form("message_field")
  5.   Set myMail=CreateObject("CDO.Message")
  6.   myMail.Subject="Sending email with CDO"
  7.   myMail.From="mymail@mydomain.com"
  8.   myMail.To= to
  9.   myMail.HTMLBody = message
  10.   myMail.Send
  11. %>


Obviously you'll need additional processing to check if it's a valid email address, whether the text entered contains illegal characters etc.
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

um very helpful thank you katana!!!
im still having problems..i might have to post all the code up!

;-((
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

"Obviously you'll need additional processing to check if it's a valid email address, whether the text entered contains illegal characters etc."

what sort of code are we talking?ad refferances?
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

No probs, that's what this place is for ;) :D
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

Well, you'll want to check that the email address at least contains the 'at' symbol (@), otherwise strange and unearthly things may happen.
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

right im gona sound so dumb...

iv got two pages in a testing folder on my ISS!(wwwroot)

the folder is called email inside the folder my two files
- 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>

and page to
- sendemail.asp
<%
dim to, message
to = 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
myMail.HTMLBody = message
myMail.Send
%>

this is not working, im not suprised cos i think it looks very wrong
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

What is causing it not to work? What (if any) error message are you getting?
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

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.xx.xxx 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:
Microsoft VBScript compilation (0x800A03F2)
Expected identifier
/email/sendemail.asp, line 2, column 4
dim to, message
---^

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

* Page:
POST 60 bytes to /email/sendemail.asp

* POST Data:
to_field=pri.amin%40gmail.com&message_field=hello+email+test

* Time:
22 February 2005, 22:17:41

* More information:
Microsoft Support

error message!

right another Q, is it safe to give people my IP address to access my website>
i.e
80.108.63.2/email/email.asp

Safe??
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

Just a thought (I don't have Visual Studio at home so no syntax highlighting for me), I think 'to' is a reserved keyword. change it to something else and give it a try (i.e. to_field)
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

ok...
in the 2nd page
-sendemail.asp

<%
dim to, message
to = 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
myMail.HTMLBody = message
myMail.Send
%>

change the above
myMail.To=to
to
myMail.To_Field=to

is that right?
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

No, no. Change the variable 'to':

Code: [ Select ]
<%
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
%>
  1. <%
  2. dim to_field, message
  3. to_field = Request.Form("to_field")
  4. message = Request.Form("message_field")
  5. Set myMail=CreateObject("CDO.Message")
  6. myMail.Subject="Sending email with CDO"
  7. myMail.From="pri.amin5@hotmail.com"
  8. myMail.To= to_field
  9. myMail.HTMLBody = message
  10. myMail.Send
  11. %>
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

no
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 xxx.x.xxx.xxx 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 (0x80040220)
The "SendUsing" configuration value is invalid.
/email/sendemail.asp, line 10

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

* Page:
POST 50 bytes to /email/sendemail.asp

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

* Time:
22 February 2005, 22:34:23

* More information:
Microsoft Support

do i need a third page for the confirmation page?
and do i need to specify the email address in the code?
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

It's a CDO error this time, which means that the last one has been sorted. Have you set it up so that CDO knows the address of your SMTP server etc?

Google for the text " CDO.Message.1 (0x80040220) ", one of the results is this: http://www.webmasterworld.com/forum47/1941.htm
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

are u trying to be funny?
i have to sign up to that fourm!!
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

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.
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

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
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

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.
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

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
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

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.
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

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
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

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").
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

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
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

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
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

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
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

That sounds about right.

Give it a try and let me know how it goes.
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

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
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

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
  • pritesh_a
  • Graduate
  • Graduate
  • pritesh_a
  • Posts: 158
  • Loc: South London/UK

Post 3+ Months Ago

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
  • Posts: 2391
  • Loc: Edinburgh, Scotland

Post 3+ Months Ago

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

Post Information

  • Total Posts in this topic: 52 posts
  • Users browsing this forum: No registered users and 64 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.