Print Page | Close Window

Post to Email and Database

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=2716
Printed Date: 29 March 2026 at 4:22am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Post to Email and Database
Posted By: 288enzo
Subject: Post to Email and Database
Date Posted: 14 May 2003 at 6:30pm
Hello,

Can anyone tell me how to post form results to both an email and to a database via using one submit button?

Thanks in advance for the advice.

I also posted this message in the Database section, wasn't sure where is should go.



Replies:
Posted By: 288enzo
Date Posted: 15 May 2003 at 11:44am
No one seems to be replying, does this mean that it cannot be done?


Posted By: Mart
Date Posted: 15 May 2003 at 11:57am
It can be done just put your email script and your database script on the same page that your form is posting or getting to pretty simple really...


Posted By: 288enzo
Date Posted: 15 May 2003 at 12:24pm
Okay, so I figured out that my question is relating to html and not asp (I think).
But my questions still stands:
How do I incorperate the following onto one page?
<FORM METHOD="POST" ACTION="mailto:your email address">
<FORM METHOD="POST" ACTION="http://www.************/postnew.asp">

I two actions that I want to accomplish. You tell me to put my email script on the same page as my posting form, well I don't have an email script as you can see above, I am using the mailto: command.

If everyone isn't sure as to what it is that I need to do can someone point me to a link that might have the info. I have been searching google far and wide.

Thanks.


Posted By: fernan82
Date Posted: 15 May 2003 at 1:06pm

you don't need to incorporate those, you just send the form to postnew.asp like:

<form method="post" action="postnew.asp">

then on postnew.asp you can have a script that emails the form to you, there's some tutorial on how to send emails from and asp script on this site, you might want to read them....

<edit> Another trick if you don't have an email component or want to use the mailto: command for some reason try including this javascript on your postnew.asp:

<script>
function submitform() {
    document.myform.submit();       
}

</script>

<body onLoad="submitform()">

<form name="myform" action="mailto: youremail">
..
.. All your hidden vars
..
</form>

<!-- your page html here -->

</body>

right after your asp code, that will autosubmit a hidden form to your email from the postnew.asp



-------------
FeRnAN
http://www.danasoft.com/">


Posted By: 288enzo
Date Posted: 15 May 2003 at 1:25pm

Thanks for help and pointing me in the right direction.  I think what it is that I am looking for was like you said on this site.

 ASP Web Based Email Using Microsoft's CDONTS

I am going to try it out, wish me luck and thanks for the script.



Posted By: 288enzo
Date Posted: 15 May 2003 at 11:57pm
Okay, CDONTS is working very well. I was able to use a form field for the objNewMail.To, which is very nice. My question is how do I mix and match text with form results in the body and subject?
I tried the following and it didn't work:
objNewMail.Subject = "Thank you" nbsp;request.form("field1")nbsp;request.form("field2"

Anyone ideas?


Posted By: 288enzo
Date Posted: 15 May 2003 at 11:58pm
objNewMail.Subject = "Thank you" nbsp;request.form("field1")nbsp;request.form("field2")

forgot the last )

Question still stands.


Posted By: 288enzo
Date Posted: 16 May 2003 at 12:08am
Figured it out:

objNewMail.Subject = "Thank you " & request.form("field1") & request.form("field2")

New question:

What I would like to do is put the ID in the subject. I tried objNewMail.Subject = request.form.("id") but when the email is sent the field is blank. When a new entry is saved in the database it will automatically generate a new id#, how can you pull that new id# and show it in the email? Not sure what it is that I am doing wrong here.

Thanks in advance.


Posted By: b_bonnett
Date Posted: 16 May 2003 at 4:28am
My guess would be to first add it to the database i.e.
rstResults.AddNew
...
rstResults.Update

then use intIDNumber = rstResults.Fields("ID") to get the ID number.

Hope this helps,
Blair

-------------
Webmaster, http://www.planegallery.net/ - The Plane Gallery
Greetings From Christchurch


Posted By: 288enzo
Date Posted: 16 May 2003 at 4:54pm

That is pretty much what I was doing.  My script is the following:

rsAddListing.Update

intIDNumber = request.form("id")

Dim objNewMail
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
objNewMail.From = mailto:********@*****.com - ********@*****.com
objNewMail.To = request.form("email")
objNewMail.Subject = "New Listing #" & intIDNumber
objNewMail.Body = "This is the body of the test email."
objNewMail.Send
Set objNewMail = Nothing

rsAddListing.Close


Set rsAddListing = Nothing
adoCon.Close
Set adoCon = Nothing

But all I get in my subject line is "Listing #"

I tried @@identity but couldn't get it to work either.  Please help - frustration starting to kick in.



Posted By: ljamal
Date Posted: 16 May 2003 at 11:54pm
try
    intIDNuumber = sAddListing.Fields("ID")
where ID is the autonumber field for the table,
instead of
    intIDNumber = request.form("id")



Posted By: 288enzo
Date Posted: 17 May 2003 at 8:37am

ljamal I tried your suggestion and got the following error:

 Microsoft VBScript runtime error '800a01a8'

Object required: 'sAddListing'

/postnewlisting.asp, line 72

Bunce, I am using MS Access 2002.  What is it that I am doing wrong?

 



Posted By: ljamal
Date Posted: 17 May 2003 at 8:40am
Add an r to sAddListing
it should be rsAddListing


Posted By: 288enzo
Date Posted: 17 May 2003 at 6:19pm
Tried you suggestion with no luck.  Thanks for trying though.


Posted By: 288enzo
Date Posted: 17 May 2003 at 8:54pm

Thanks everyone, but I figured it out.  All I needed to do was add the following after my update statement.

rsAddListing.movelast

and that did it.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net