How to Email a form

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.
birosraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TTomCommented:
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
mgoergenCommented:
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
garthmillerCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
birosraAuthor Commented:
What is JMail?
I'd rather not load/use any additional software.  I was searching for a cleaner solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.