Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 21st, 2004, 02:10 AM
Registered User
 
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using CDONTS.NewMail to Send, uh, New Mail

Hey ALl,
I'm new and really only know some html.
I'm trying to create a wbpage with a simple forum on it which will send mail to me with whatever the person who submitted it entered. Except I want it to submit on server side not client.
I have found this code and tryed it but doesn't seem to send. I've only uploaded it onto a geocities website, will that work?

Here's the link for the article http://imar.spaanjaars.com/QuickDocID.aspx?QUICKDOC=249

And here's the code:

<body>
  <form id="frmSendEmail" method="post" action="SendMail.asp">
    Your name: <input type="text" name="txtName" id="txtName" /><br />
    Your message: <textarea name="txtMessage" id="txtMessage" cols="40"
         rows="10"></textarea><br />
    <input type="submit" name="btnSubmit" id="btnSubmit"
          value="Send Message" />
  </form>

</body>


At the top of your page, right before the opening <html> tag, add this ASP code:


<%
  If Request.Form("btnSubmit") <> "" Then
    Dim UserName
    Dim UserMessage
    UserName = Request.Form("txtName")
    UserMessage = Request.Form("txtMessage")
    Dim Message
    Message = "Mail from the Web site" & vbCrlf & vbCrLf
    Message = Message & "User " & UserName & _
         " left the following message: " & vbCrLf
    Message = Message & UserMessage & vbCrLf & vbCrLf

    Dim oMessage
    Set oMessage = Server.CreateObject("CDONTS.NewMail")

    Const CdoBodyFormatHTML = 0 ' Send HTML Mail
    Const CdoBodyFormatText = 1 ' Send Text Mail

    Const CdoMailFormatMime = 0 ' Send mail in MIME format.
    Const CdoMailFormatText = 1 ' Send mail in uninterrupted
                                ' plain text (default value).

    With oMessage
      .To = "[email protected]"
      .Bcc = "[email protected]"
      .From = "[email protected]"
      .Subject = "User " & UserName & " left a message"
      .BodyFormat = CdoBodyFormatText ' CdoBodyFormatHTML
      .MailFormat = CdoMailFormatMime ' CdoMailFormatText
      .Body = Message
      .Send
    End with
    Set oMessage = Nothing

    Response.Redirect("ThankYou.asp")
  End If

%>
<html>




How can I make this work. Keep in mind I'm a n00b and i really need things broken down. Also will i need something better than geocities?

I truly appreicate any help.

THanks,
Patrick

 
Old November 21st, 2004, 08:04 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Patrick,

Are you sure Geocities supports sending e-mail from an ASP page with your hosting package?

Usually, Web hosts provide a FAQ for these kind of topics, showing the code you need to send e-mail (if even allowed).

Did you check their help / FAQ section??

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old November 21st, 2004, 11:50 AM
Friend of Wrox
 
Join Date: May 2003
Posts: 202
Thanks: 0
Thanked 1 Time in 1 Post
Default

Assuming that Geocities even supports sending mail through ASP, the problem might be that you need to use CDOSYS instead of CDONTS.

CDONTS is no longer installed by default on IIS. Apparently CDONTS is considered to have some security vulnerabilities and Microsoft has strongly suggested (by no longer including CDONTS) everyone migrate to CDOSYS.

Imar -

You should probably update your ASP Email page with this info and/or add an example of using CDOSYS instead.

Bruce Luckcuck
Director, Applications & Support Services
Wiley Publishing, Inc.
 
Old November 21st, 2004, 12:17 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It's already in there; the second half of the article shows how to send mail with CDOSYS / a CDO.Message object.

I could add a bit about Server 2003, though....


Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Attach E-mail in CDONTS jmss66 Classic ASP Basics 8 March 25th, 2004 09:18 PM
CDONTS send mail for Earthlink egerdj Wrox Book Feedback 1 February 17th, 2004 05:50 PM
Sending both text mail and HTML mail - CDONTS madhukp Classic ASP Basics 1 October 8th, 2003 01:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.