473,394 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Web page, attach the form to the email

Hi there.

I am looking for a way to generate a report from a web form and attached it to an email so that I could send it.

The form is retrieving data from a Microsoft SQL server and display them in a print out ASP page.

There is a print button and an email button in javascript in the form. However, nothing is attached to the email at this point.

Could any one herl?

Expand|Select|Wrap|Line Numbers
  1. <form>
  2. ....etc
  3.  
  4. <td><input type="button" value="Print this page " onclick="window.print();return false;" /></td>
  5. <td>&nbsp;<input type="button" value="Email" onclick="location.href='mailto:'" /></td>
  6.  
  7. </form>
  8.  
Aug 13 '08 #1
6 2810
RamananKalirajan
608 512MB
Hi, one thing u can do. Just inside the form, have unique id for every element and onSubmit invoke a function that will retrieve all the form values and pass it as a string to the mail. Just try out this if needed help post it. I will try to help u out.

Regards
Ramanan Kalirajan
Aug 13 '08 #2
acoder
16,027 Expert Mod 8TB
The best way to send email is to use server-side.

However, you can do without though it will be unreliable and depend on the user having an email client set up and they can send emails. This method just requires you to set the action of the form to a mailto: address.
Aug 13 '08 #3
Hi, one thing u can do. Just inside the form, have unique id for every element and onSubmit invoke a function that will retrieve all the form values and pass it as a string to the mail. Just try out this if needed help post it. I will try to help u out.

Regards
Ramanan Kalirajan

HI Ramanan,
Would you please give me some reference or example of how you do it?
Aug 17 '08 #4
RamananKalirajan
608 512MB
HI Ramanan,
Would you please give me some reference or example of how you do it?
This is an Example. But here all the form variable will be submitted.

[HTML]<html>
<body>
<h3>This form sends an e-mail to the user you specified in the Action</h3>
<form id="thisForm" method="post" enctype="text/plain">
Name:<br />
<input type="text" name="name"
value="yourname" size="20" />
<br />
Mail:<br />
<input type="text" name="mail"
value="yourmail" size="20" />
<br />
Comment:<br />
<input type="text" name="comment"
value="yourcomment" size="40" />
<br /><br />
<input type="Button" value="Mail" onclick="mailMe()"/>
<input type="reset" value="Reset" />
</form>
</body>
</html>
<script type="text/javascript">
function mailMe()
{
// alert("Inside Mail");
var myForm = document.getElementById('thisForm');
myForm.action="MAILTO:****@excelacom.in";
myForm.submit();
}
</script>[/HTML]

You can achieve this in another way also. Have two forms within the same page. In one form you put your all input elements. In the other form just have an input hidden field, when the form is subitted collect all the values in the form1 set that value to the hidden element in the 2md form and submit using mail. Further doubts please post it back

Regards
Ramanan Kalirajan
Aug 18 '08 #5
Thanks Ramanan, I tried your codes. But i have further questions.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Set conn = Server.CreateObject("ADODB.Connection")
  3. Set rs = Server.CreateObject("ADODB.Recordset")
  4. conn.Open  "Driver={SQL Native Client};.............etc
  5.  
  6. sql = "select * from returns where gra_id=" & request("gra_id")
  7.  
  8. rs.open sql, conn
  9.  
  10. %>
  11. <html>
  12. <body>
  13.  
  14. <form id="thisForm" action="print_out.asp" method="post" enctype="text/plain">
  15.  
  16. <hr>
  17. <table width="100%">
  18.  
  19. <tr>
  20. <td width="20%"><font size=4.5><b>GRA ID:</b></font></td><td  width="20%"><font size=4.5><b><%=rs("gra_id")%></b></font></td><td width="20%"><font size=4.5><b>No. of Packages</b></font></td><td width="20%"><%=rs("package")%> </td>
  21. </tr>
  22.     <tr>
  23.         <td>&nbsp;</td>
  24.     </tr>
  25. <tr>
  26. <td width="20%"><b>Enter Date:</b></td><td width="20%"><b><%=entered_date%></b></td>
  27. </tr>
  28. <tr>
  29. <td width="20%"><b>Customer Account:</b></td><td width="20%"><%=rs("account")%></td><td width="20%"><b>CSL Invoice No:</b></td><td width="20%"><%=rs("invoice")%></td> <td width="20%"></td>
  30. </tr>
  31. </table>
  32. .........................etc
  33.     <hr />    
  34.  
  35. <table>
  36. ..........................etc
  37.     <tr>
  38.         <td>&nbsp;</td><td><input type="button" value="Print this page " onclick="window.print();return false;" /></td>
  39.         <td>&nbsp;<input type="button" value="Email" onclick="mailForm()" /></td>
  40.     </tr>
  41. </table>
  42. </form>
  43. </body>
  44. </html>
  45. <%
  46.     rs.close
  47.     conn.close
  48.  
  49.     %>
  50.  
  51. </body>
  52. </html>
  53.  
  54. <SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
  55. <!--
  56. function mailForm()
  57.    {
  58.      // alert("ubside Mail")
  59.      var myForm = document.getElementById('thisForm');
  60.      myForm.action="MAILTO:****@cuthbertstewart.co.nz";
  61.      myForm.submit();
  62.    }
  63.  
  64. //-->
  65. </script>
  66.  

My page is retrieving data (VBscript, ADO) through the database so without any textfield available. Is like a report I want to email to people.

I tried the code, however is not attaching with the email if it is not using the input type.

I can print out the form as PDF. Am I able to email the form as an attachment instead?
Aug 18 '08 #6
RamananKalirajan
608 512MB
Still u can achieve ur requirement without attaching the PDF. In HTML DOM you are having an element input type="hidden" this variable can hold the value which u retrieve from the DB. pass this value to the mail. Try this out. Still any doubts post it back i will try to help u out.

Regards
Ramanan Kalirajan
Aug 19 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: tp | last post by:
HI... I have created simple .asp page and i would like to send my page as email using my outlook . is it possible to send form body as new email outlook body using mailto command or any other...
3
by: tp | last post by:
Hi... I have web page and i would like to use "Page by Email" commad in my page which we use with regular word ,excel and IE 5. any body know the code that i can fire page by email directly...
4
by: Rahul Chatterjee | last post by:
Hello All I have a web page which has a registration form. The user inputs data in the form and I would like to be able to send the entire form contents to an email address (In the HTML format)....
6
by: Robert-SoftMAR | last post by:
How i can repair database ms-sql when attach file i have: error 823 I/O error (bad page ID) detected during read at offset 0x itd... Robert Lis
7
by: joey.powell | last post by:
I have a home page with username and password textboxes and a login button for purposes of users being able to log in (forms authentication) directly on the site home page. I also have a dedicated...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
5
by: Jess | last post by:
I'm trying to build a page that the user can attach a file/s to and email them thru a form. I see plenty of info on how to actually code it to send with a variable - but how do you build a form...
2
by: calebmichaud | last post by:
Hi I am having trouble understanding how to attach a file or files to a record. I want to (in form view0 allow the user to attach one or more than one file to the associated record, and then...
7
by: Inny | last post by:
Hello again, Im using the code below in a child page (popup), the images are called from the parent page. When the changer is running, the child page goes white between images. I realise this is...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.