Solved

Automatic Email After [Dreamweaver MX '04] Record Insert

Posted on 2003-10-22
18
296 Views
Last Modified: 2008-03-06
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
Comment
Question by:movoni
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
  • 2
  • +2
18 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9604208
movoni,
Try this :
Instead of Request.Form()
change to
Request()

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

Regards
x_com
0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9604230
movoni,
make sure the fieldname that you're trying to request is correct.

x_com
0
 

Author Comment

by:movoni
ID: 9604250
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9604271
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
 

Author Comment

by:movoni
ID: 9604286
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
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9604305
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
 
LVL 21

Expert Comment

by:Randy Poole
ID: 9604422
Can you post your querystring from your previous page that is calling this page.
0
 

Author Comment

by:movoni
ID: 9604613
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
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9604627
movoni,
Put this two statement for any debug process :
Response.Write()
Response.End

Waiting you to post the whole code here.

x_com
0
 
LVL 15

Expert Comment

by:gladxml
ID: 9604700
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
 

Author Comment

by:movoni
ID: 9604720
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
 

Author Comment

by:movoni
ID: 9604725
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
 
LVL 15

Assisted Solution

by:gladxml
gladxml earned 125 total points
ID: 9604729
0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 250 total points
ID: 9604922
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
 
LVL 21

Assisted Solution

by:ap_sajith
ap_sajith earned 125 total points
ID: 9605092
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
 

Author Comment

by:movoni
ID: 9611471
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
 

Author Comment

by:movoni
ID: 9611484
Sorry.. and I meant glad too because his articles helped me figure this out too.
0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9612094
Glad to help, movoni

Regards
x_com
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question