Automatic Email After [Dreamweaver MX '04] Record Insert

All --

I'm asking here instead of Dreamweaver as I beleive this to be more ASP-related.  That said, I am using Dreamweaver MX 2004.

My page has a really long form, so I'll spare you that code.  However, it inserts the form into an SQL db.  That works fine.  Then I have the code below to automatically email the user saying thanks for filling out the form, etc., etc.  The email goes out fine.  However, I want it to also send variables from the form -- username and password.  It also has to pull from the form's email field to get the user's email address.  The variables just won't work no matter where I drop it into the page -- I've tried both session variables and form.requests.  I can't get it to send the variables over to the next page (a thanks page) or to the email that the user gets.  Here's the code for the email itself.

'*********** SEND EMAIL AFTER DB OPERATIONS ***********

Dim myMail
Set myMail = CreateObject("CDONTS.NewMail")
'myMail.AttachURL "c:\images\logo.gif", "logo.gif"
'myMail.AttachURL "c:\images\new.gif", "new.gif"

HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<meta http-equiv=""Content-Type"""
HTML = HTML & "content=""text/html; charset=iso-8859-1"">"
HTML = HTML & "<title>Your Account</title>"
HTML = HTML & "</head>"
HTML = HTML & "<body bgcolor=""#FFFFFF"">"
HTML = HTML & "<p><font size=""2"" face=""""Arial, Helvetica, sans-serif"">Dear"

HTML = HTML &  Request.Form("FIRST_NAME")

HTML = HTML & ",</font></p>"
HTML = HTML & "<p><font size=""2"" face=""Arial, Helvetica, sans-serif"">Thank you for submitting your information blah, blah, blah.</font></p>"
HTML = HTML & "<p><font size=""2"" face=""Arial, Helvetica, sans-serif"">For your convienience, you may edit your Profile at any time by visiting our <a href="""">Client Admin Interface</a>.  Your username is"
HTML = HTML & " and your password is "

HTML = HTML & "<p>Email continues with more blah, blah."

HTML = HTML & "</body>"
HTML = HTML & "</html>"

myMail.From = ""
myMail.To = Request.Form("CLIENT_EMAIL")
myMail.Subject = "Your Movoni Account"
myMail.BodyFormat = 0
myMail.MailFormat = 0
myMail.Body = HTML
'*********** END SEND EMAIL ***********

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David H.H.LeeCommented:
Try this :
Instead of Request.Form()
change to

Change to

David H.H.LeeCommented:
make sure the fieldname that you're trying to request is correct.

movoniAuthor Commented:
That didn't do it x. :(

It's frustrating that I really can't post all of my code (for various reasons), but to shed some light, I did create a form on a brand new page with nothing but one field and a button.  The request.form worked on that test page *IF* I turned the code into a Sub routine and called the Sub from the button like this: onclick="<% CALL SendMail() %>">

However, if I take that call away (and take away the Sub/End Sub) and try to let it run without any user action (like I am trying to do in my question above), the variables aren't read.  Weird.

OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

David H.H.LeeCommented:
Can you get value for Request.Form("FIRST_NAME") in this form?
to see what you get. Make sure you're not getting a blank value.
-You have 1 page or 2 page in this case? Are you trying to re-post to same page or others page?

movoniAuthor Commented:
Hmmm... I took away the success page link so the form doesn't go anywhere after it submits and ya' know what... the response.write isn't showing up.  So... lemme move that little response.write around until it shows up, them we'll go from there.  Hold pls ;)

David H.H.LeeCommented:
Possible to show your full code here?maybe you can make a dumb code here.
This mean you're re-post the submitted value into same page?Try to use Response.Write() untill you see the value if you not intend to post your code here. Then, your problems should be solve.

Randy PooleCommented:
Can you post your querystring from your previous page that is calling this page.
movoniAuthor Commented:
rp - I'm going to clean up the code so I can post it publicly.  I'll mess with that and trying to get the response.write to work too (from above in the thread).  I'm going to work on it a little more first.  Be back sometime tomorrow...

David H.H.LeeCommented:
Put this two statement for any debug process :

Waiting you to post the whole code here.


How do you post when you insert the data on the insert statement... I mean the form action

1. post it on the same page...
2. post it on other page...

If you will put the value son other form or pages... This is just an educated guess instead of using response.redirect try to use server.transfer...
For more info try to chek out the link....


HAppy programming...
movoniAuthor Commented:
I'll check that out.  Since this app is being developed in Dreamweaver, I am using their built-in Behaviors (otherwise I'd still be stuck at the <BODY> tag ;)  Dreamweaver makes the code for inserting a record with a single mouse click on the development side.  The form action points to an ASP sub routine and that sub has a ton of code that I barely understand.  I basically filled out a form and said insert these fields into the db and then take the users to this "thanks" page.

What I'm trying to do is email them a thanks as well.  The form is POST (GET doesn't work) so I can carry on a URL variable that I know of.  What I've been trying to do is paste my initial code above into the area just before the form data is inserted into the db and just after the form validation tags.  The email goes out no matter where I paste the code for the most part... it's the doggone variables that I can't get to go into the email.

Whew.  I don't think it makes since to post ALL of my code for my own parnoid reasons, but I'm going to try to clean it up or maybe duplicate what I'm trying to do in another file.  I'll take a look at your link.

movoniAuthor Commented:
I meant I "CAN'T" carry a URL string with POST that I know of (plus, I wouldn't really want that long of a URL... the form is big).

- MT
David H.H.LeeCommented:
movoni ,
I think you can done in easier way :
1. Do all the process (Form filling) at formFilling.asp
    Before post the data to others page for processing, do all the validations to the required fill in space in the same page using client-side validations code.
2. After fill in all the required data in formFilling.asp
    Post all the data to process.asp. At this page, do all the DB processing. After DB processing, then continue your email processing. This level, you should get work for all the variables come from formFilling.asp. After email processing, you can redirect to "thanks.asp" as you need.

Does your structures go that ways too? I just provide the simpliest way to solve your problems.
Hope that solve your problems.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Change your Code to the like shown below

<Form name="frmInput" action="DbUpdate_SendMail.asp" Method="post">
<!-- Input fields and rest of the stuff here-->

And in DbUpdate_SendMail.asp, Write normal asp code for DB updates and once the db update is done write the email code posted by you above. Use request.Form("fieldName") to retrieve the values. DO NOT Write any email code or db update code on the onclick event. You will have to change your code to client side vbscript if you do that. For server side processing, do as i suggested above.

movoniAuthor Commented:
Ok guys...  I fixed it.

I learned that you cannot use request.form on enctype forms.  After some research into the file upload component that I am using for Dreamweaver (PureUpload 2.1), I found out that I can use a special tag -- UploadFormRequest("field here").  I set a session variable using that call to a single form field that is also a unique key in my SQL db.  I use the success page ("thanks page") to send the email to my customer.

I'm going to split the points between ap and x for all of their time and help.  Some of the thing they told me helped me to find my answer.

Thanks guys!  Hopefully this post will help someone else one day.

- Michael
movoniAuthor Commented:
Sorry.. and I meant glad too because his articles helped me figure this out too.
David H.H.LeeCommented:
Glad to help, movoni

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.