Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

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 = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & NL
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=""http://www.blah.com"">Client Admin Interface</a>.  Your username is"
HTML = HTML & Request.Form("CLIENT_USERNAME")
HTML = HTML & " and your password is "
HTML = HTML & Request.Form("CLIENT_PASSWORD")

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

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

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

Thanks,
MT
0
movoni
Asked:
movoni
  • 7
  • 7
  • 2
  • +2
3 Solutions
 
David H.H.LeeCommented:
movoni,
Try this :
Instead of Request.Form()
change to
Request()

Eg:
Request.Form("CLIENT_EMAIL")
Change to
Request("CLIENT_EMAIL")

Regards
x_com
0
 
David H.H.LeeCommented:
movoni,
make sure the fieldname that you're trying to request is correct.

x_com
0
 
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.

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
David H.H.LeeCommented:
movoni,
Can you get value for Request.Form("FIRST_NAME") in this form?
Use
Response.Write(Request.Form("FIRST_NAME"))
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?

Regards
x_com
0
 
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 ;)

Thanks,
MT
0
 
David H.H.LeeCommented:
movoni,
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.

Regards
x_com
0
 
Randy PooleCommented:
Can you post your querystring from your previous page that is calling this page.
0
 
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...

Thanks,
MT
0
 
David H.H.LeeCommented:
movoni,
Put this two statement for any debug process :
Response.Write()
Response.End

Waiting you to post the whole code here.

x_com
0
 
gladxmlCommented:
movoni,

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....

http://www.w3schools.com/asp/met_transfer.asp

HTH...

HAppy programming...
0
 
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.

Thanks!
Michael
0
 
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
0
 
gladxmlCommented:
0
 
David H.H.LeeCommented:
movoni ,
I think you can done in easier way :
Eg:
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.

Regards
x_com
0
 
ap_sajithCommented:
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-->
</Form>

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.

Cheers!!
0
 
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
0
 
movoniAuthor Commented:
Sorry.. and I meant glad too because his articles helped me figure this out too.
0
 
David H.H.LeeCommented:
Glad to help, movoni

Regards
x_com
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 7
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now