Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Email form with both attach attachment button and send email button in it

Posted on 2006-05-28
4
Medium Priority
?
215 Views
Last Modified: 2012-05-05
I am slowly figuring out sending emails with attachments using CDO.
I have an email form with usual to, from, subject and message inputs and then have a button with a value "upload attachment" when clicked this submits the form to the next page where the user browses for and uploads a file attachment and then submits this file for attachment with the email.

How can I include a second button on the original email form with a value"Send Email" for the user to click when they do not want to attach any attachments just simply send the email form as is?

Thanks for your help.
0
Comment
Question by:rabbits2
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
Hecatonchires earned 1200 total points
ID: 16786997
add to your form
<input type='hidden' name='reallysendemail' value='false' />
<input type='submit' value='Send Email' onClick='document.forms[0].reallysendemail.value="true"; return true;' />

(or possible return false)

when you submit to your email sending, attachment adding page, query the value of reallysendemail.  if its true, send the email, otherwise add an attachment.

alternative is change the action location of the form, and redirect to a different pge entirely.
0
 

Author Comment

by:rabbits2
ID: 16788785
That makes sense, but could you please explain in a bit more detail:

1. Why 'or possible return false'

I have tried this idea by have the
<input type='hidden' name='reallysendemail' value='false' />
<input type='submit' value='Send Email' onClick='document.forms[0].reallysendemail.value="true"; return true;' />
and then on the second page:

sendornot = Request.Form ("reallysendemail")
If sendornot ="true" Then

'send email using CDO
Response.Write "You have successfully sent the email"

Else

'write the page including the file attachment form

But whenever I click on the 'Send Email' button on the first page I seem not to be changing the value of 'reallysendemail' as the file attachment form writes on the second page.
Could it be to do with my form name on the first page being 'formemail' and therfore perhaps I must change the form name in this line:
<input type='submit' value='Send Email' onClick='document.forms[0].reallysendemail.value="true"; return true;' />

to:
<input type='submit' value='Send Email' onClick='document.forms[formemail].reallysendemail.value="true"; return true;' />

Just tested that and I am still getting the value of reallysendemail as 'false' when I press the 'Send Email' button.

Any ideas, thanks
0
 

Author Comment

by:rabbits2
ID: 16791695
This works:

<input type='hidden' name='reallysendemail' value='' />
                      <input type='submit' value='Send Email' onClick='document.formemail.reallysendemail.value="true"; return true;' />
                     

Thanks!
0
 
LVL 7

Expert Comment

by:Hecatonchires
ID: 16794246
yeah, the javascript was a bit spotty.  i can never remember if you return true to make the script continue, or false to make the script continue.  also, if u have more than one form, it may not be forms[0], so naming the form is a good idea.  glad it works.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

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…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Loops Section Overview
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month20 days, 15 hours left to enroll

810 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