[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How to Email a form

Posted on 1999-12-13
4
Medium Priority
?
252 Views
Last Modified: 2013-12-24
I am using Front Page 98.
Load this simple HTML and run

<html>

<head>
<title>Form with all fields</title>
<script LANGUAGE="JavaScript">
//
if (window.focus) self.focus();

function kochharcheck(){
if ((checklastname()) && (checkfirstname())  && (checkemailone()))
{
alert("Thank you for submiting this form")
return true
}
else
  return false;
}
function checkname(kocha){
koch = "";
for (k = 0; k < kocha.length; k++)
{
koc = kocha.substring(k, k+1);
if ((koc >= "A" && koc <= "Z") || (koc >= "a" && koc <= "z") || (koc == "'"))
{
koch += koc;
}
}
if (kocha!= koch) {
if (confirm("You entered spaces or invalid characters.\n\nClick OK to fix this.\n\nClick CANCEL to leave unchanged")) {
return koch;
}  
{
return kocha;
}
}
return kocha;
}
function checklastname(){
var kocha= document.kochhar.lastname.value
if (document.kochhar.lastname.value == "")
 {
alert("Please enter your last name.")
document.kochhar.lastname.focus();
return false;
}
{
b = kocha.substring(0,1);
c = kocha.substring(1,kocha.length);
document.kochhar.lastname.value = b.toUpperCase() + c.toLowerCase();
}
return true;
}
function checkfirstname(){
var kocha= document.kochhar.firstname.value
if (document.kochhar.firstname.value == "")
 {
alert("Please enter your first name.")
document.kochhar.firstname.focus();
return false;
}
{
b = kocha.substring(0,1);
c = kocha.substring(1,kocha.length);
document.kochhar.firstname.value = b.toUpperCase() + c.toLowerCase();
}
return true;
}

function check(kocha){
koch = "";
for (k = 0; k < kocha.length; k++)
{
koc = kocha.substring(k, k+1);
if ((koc >= "A" && koc <= "Z") || (koc >= "a" && koc <= "z") || (koc == "/") || (koc == "\\") || (koc == "[") || (koc == "]") || (koc == "_") || (koc == "-") || (koc >= "0" && koc <= "9"))    
{
koch += koc;
}
}
if (kocha!= koch) {
if (confirm("You entered spaces or invalid characters.\n\nClick OK to fix this.\n\nClick CANCEL to leave unchanged")) {
return koch;
}  
{
return kocha;
}
}
return kocha;
}
function checkemail(){
kocha=document.kochhar.email.value;
koch = "";
for (k = 0; k < kocha.length; k++)
{
koc = kocha.substring(k, k+1);
if ((koc >= "A" && koc <= "Z") || (koc >= "a" && koc <= "z") || (koc == "@") || (koc == "[") || (koc == "]") || (koc == ".") || (koc == "_") || (koc == "-") || (koc >= "0" && koc <= "9"))
{
koch += koc;
}
}
if (kocha!= koch) {
if (confirm("You entered spaces or invalid characters.\n\nClick OK to fix this.\n\nClick CANCEL to leave unchanged")) {
return koch;
}  
{
return kocha;
}
}
return kocha;
}
function checkemailone(){
var kocha = document.kochhar.email.value
if (document.kochhar.email.value == "")
 {
alert("Please enter your e-mail.")
document.kochhar.email.focus();
return false;
}
{
kocha=document.kochhar.email.value;
b = kocha.substring(0,1)
if (b == '@')
{
alert("Please check your e-mail.  There must be a prefix before '@'.\n\nExample: jmax@aol.com")
document.kochhar.email.select();
document.kochhar.email.focus();
return false;
}
if ((kocha.indexOf("@") == -1) || (kocha.indexOf(".") == -1))
{
alert("Please check your e-mail.  The e-mail address must include the '@' and '.' signs.\n\nExample: jmax@aol.com");
document.kochhar.email.select();
document.kochhar.email.focus();
return false;
}
{
c = kocha.indexOf("@")
d = kocha.indexOf(".");
e = kocha.substring(c,d);
if (e.length < 2)
{
alert("You must enter something between the \"@\" and \".\" signs")
document.kochhar.email.select();
document.kochhar.email.focus();
return false;
}
{
b = kocha.indexOf(".")
kocha= kocha.substring(b,kocha.length);
if (kocha.length <2)
{
alert("You must enter at least 1 character after '.'")
document.kochhar.email.select();
document.kochhar.email.focus();
return false;
}
}
return true;
}
}
}
function hamlet(){
document.kochhar.lastname.value = "";
document.kochhar.firstname.value = "";
document.kochhar.email.value = "";
document.kochhar.lastname.focus();
}
//-->
</script>
</head>

<body onload="hamlet()" bgcolor="#FFFFD5" link="#000080" vlink="#004000" alink="#FF8000">

<blockquote>
  <p>&nbsp;</p>
</blockquote>

<form method="post" name="kochhar" ENCTYPE="text/plain"
ACTION="mailto:myaddress@myplace.com" onsubmit="return kochharcheck()">
  <div align="left"><table border="1" cellpadding="0" cellspacing="0" width="547"
  height="42">
    <tr>
      <td width="271" height="30" align="left"><font color="#000000" size="2" face="Verdana"><strong>Last
      Name</strong></font></td>
      <td width="249" height="30"><input type="text" name="lastname" size="20"
      onchange="this.value=checkname(this.value);checklastname()"></td>
    </tr>
    <tr>
      <td width="271" height="30" align="left"><font color="#000000" size="2" face="Verdana"><strong>First
      Name</strong></font></td>
      <td width="249" height="30"><input type="text" name="firstname" size="20"
      onchange="this.value=checkname(this.value);checkfirstname()"></td>
    </tr>
   
    <tr>
      <td width="271" height="9" align="left"><font color="#000000" size="2" face="Verdana"><strong>E-Mail</strong></font></td>
      <td width="249" height="17"><input type="text" name="email" size="25"
      onchange="this.value=checkemail()"></td>
    </tr>
    <tr>
      <td width="782" height="24" colspan="2"></td>
    </tr>
    <tr>
      <td width="782" height="24" colspan="2"><div align="center"><center><p>&nbsp; <input
      type="submit" value="Submit">&nbsp; <input type="reset" value="Reset" onclick="hamlet()"></td>
    </tr>
  </table>
  </div>
</form>
</body>
</html>

When you press SUBMIT, after a few dialogs, you get placed in your mail program but in my case (using Microsoft Outlook) I do not get my form as an attachment.

I've tried using the FP98 Form E-Mail Results feature but the format options they provide are ugly when received on the other end.
0
Comment
Question by:birosra
4 Comments
 
LVL 9

Expert Comment

by:TTom
ID: 2277643
I would venture to guess that the way to get this info is in the form encoding property.  May need to be ENCTYPE="multipart/form-data".  Not sure what else might need to be done to make this work.

I found some additional information on:

http://www2.lysator.liu.se/~jmo/elements/form.html

but it seems to indicate that what you want to do may not be possible on an email form submission.

Tom
0
 
LVL 1

Expert Comment

by:mgoergen
ID: 2279525
I guess the simplest way to send the form data via attachment is using a cgi script, but do you really want to send the datas as an attachment?

If you prefer the attachment / cgi script combination you can for example store the information of the form in a local file. And send this file via mail.
0
 

Accepted Solution

by:
garthmiller earned 120 total points
ID: 2280331
You can send form data as an attachment to an email if you use an ASP page.

I like to use Jmail to send email from my ASP pages.  You can download it for free from http://www.dimac.net

Once you have it installed on your server, you can make an ASP page for your form to call.  If your new page is called myform.asp your <form> tag should look like this:

<form method="post" name="kochhar" ACTION="myform.asp" onsubmit="return kochharcheck()">

Then the code for your new asp page should look like this:

<%
Set JMail =
  Server.CreateObject ("JMail.SMTPMail")
JMail.ServerAddress = "my.email.server"
JMail.Sender = "Web Form"
JMail.Subject = "Mail from Web Form"
JMail.AddRecipient("my@email.com")
JMail.Body = "Open the attachment"
attachString =
     Request.Form("firstname") & " " 
attachString = attachString &
     Request.Form("lastname")
attachString = attachString & " " &
     Request.Form("email")
JMail.AddCustomAttachment "file.txt",
     attachString
JMail.Execute
%>
<html>
<head>
</head>
<body>
<br>
Mail was sent successfully!
</body>
</html>

By using the JMail AddCustomAttachment method, you avoid having to create a file to send as an attachment.  Instead you can put whatever you want into the variable called attachString (even HTML code) and it will show up as an attached file when the email arives.

Garth Miller
0
 

Author Comment

by:birosra
ID: 2297519
What is JMail?
I'd rather not load/use any additional software.  I was searching for a cleaner solution.
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

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

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
Suggested Courses

591 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