Forums
This topic is locked
formmail
Posted 20 Sep 2005 14:59:01
1
has voted
20 Sep 2005 14:59:01 andy bertaut posted:
right now i have a couple of forms on a site wizard.ie, and although I know it isn't the best way to do it, I have them being submitted using the mailto: action. this WAS working, and i know I have used it before and it worked fine. Now, however, it is trying to open a mail client to send mail that way. I know there is a better method involving posting to another page rather than a mailto but i have NO idea what it is...if anyone knows a fast solution to this, i'd love to hear it. Is there much involved in the method of posting the info to another page which in turn sends it? The form code is here:<form action="mailto: " method="post" enctype="text/plain" name="Contact Us Form" id="formbody" onSubmit="javascript:window.location.href='contact_confirm.asp'">
Replies
Replied 20 Sep 2005 16:32:03
20 Sep 2005 16:32:03 Michael Behan replied:
I thought it always tried to use a mail client if you were using mailto in the form action...
There's a few ways, using asp, to do what you're trying to do.
the way id do it is like this (asp vbscript; required windows 2000 server or XP i think):
I'm assuming here its a contact form with 2 fields that are called email and comments
set the form action = mailSender.asp
the page mailSender.asp should include the following (replaceing field names, email addresses etc. as required)
Set objMessage = CreateObject("CDO.Message"
objMessage.Subject = "Form Mail"
objMessage.Sender = Request("email"
objMessage.To = " "
objMessage.TextBody = Request("comments"
objMessage.Send
There's a few ways, using asp, to do what you're trying to do.
the way id do it is like this (asp vbscript; required windows 2000 server or XP i think):
I'm assuming here its a contact form with 2 fields that are called email and comments
set the form action = mailSender.asp
the page mailSender.asp should include the following (replaceing field names, email addresses etc. as required)
Set objMessage = CreateObject("CDO.Message"
objMessage.Subject = "Form Mail"
objMessage.Sender = Request("email"
objMessage.To = " "
objMessage.TextBody = Request("comments"
objMessage.Send
Replied 20 Sep 2005 22:35:49
20 Sep 2005 22:35:49 andy bertaut replied:
hi michael, thanks for the post.
the form has four fields; name, emails, phone, and body (for comments). It is asp javascript, should that effect the code you sent me?
If not then I will go ahead and try it tomorrow. I assume I'll need extra lines of code for the extra fields, so I'm just curious as to where they should be included.
Thanks again. For the heck of it, herss the code:
<form action="mailto: " method="get" name="Contact Us Form" id="formbody" onSubmit="MM_callJS('window.location.href=\'contact_confirm.asp\'')">
<table border="0" cellpadding="1" cellspacing="1" id="formbody">
<tr>
<td align=right><div align="left"><b>FreePhone:</b></div></td>
<td>
<div align="left">1800-923-200 <font color=red>NEW!
24 Hour Order Phoneline Now Open!</font> </div></td>
</tr>
<tr>
<td align=right><div align="left"><b>FreeFax:</b></div></td>
<td><div align="left">1800-923-400</div></td>
</tr>
<tr>
<td align=right valign="top"><div align="left"><b>Post:</b></div></td>
<td><div align="left">Wizard O&E, <br>
FREEPOST, <br>
Sandyford Ind. Estate, <br>
Dublin 18 </div></td>
</tr>
<tr>
<td align=right><div align="left"><strong>E-Mail:</strong></div></td>
<td><div align="left"><a href="mailto: ?subject=Mail%20From%20Site" id="formbody"> </a></div></td>
</tr>
<tr>
<td colspan=2> </td>
</tr>
<tr>
<td colspan=2><div align="left"><a href="catalogue_request.asp" id="formbody">If
you just want to order a FREE catalogue, please click here.</a></div></td>
</tr>
<tr>
<td height="10" colspan=2><div align="left" id="formbody"></div></td>
</tr>
<tr>
<td height="10" colspan=2><div align="left"></div></td>
</tr>
<tr>
<td colspan=2><div align="left"><b>Alternatively, you can send a quick
e-mail to Wizard:</b></div></td>
</tr>
<tr>
<td colspan=2><div align="left"></div></td>
</tr>
<input type="hidden" name="SendRequest" value="true">
<tr>
<td align=right><div align="left">Name:</div></td>
<td><div align="left">
<input name="Name" type="text" onBlur="MM_validateForm('Name','','R');return document.MM_returnValue">
</div></td>
</tr>
<tr>
<td align=right><div align="left">Email:</div></td>
<td><div align="left">
<input name="email" type="text" onBlur="MM_validateForm('email','','RisEmail');return document.MM_returnValue">
</div></td>
</tr>
<tr>
<td align=right><div align="left">Phone:</div></td>
<td><div align="left">
<input name="phone" type="text" onBlur="MM_validateForm('phone','','RisNum');return document.MM_returnValue">
</div></td>
</tr>
<tr>
<td align=right valign=top><div align="left">Message:</div></td>
<td><div align="left">
<textarea name="body" cols=40 rows=7 onBlur="MM_validateForm('body','','R');return document.MM_returnValue"></textarea>
</div></td>
</tr>
<tr>
<td> </td>
<td align=right><input name="submit" type=submit onClick="MM_validateForm('Name','','R','email','','RisEmail','phone','','RisNum','body','','R');return document.MM_returnValue" value="Send E-Mail"></td>
</tr>
</table>
</form>
the form has four fields; name, emails, phone, and body (for comments). It is asp javascript, should that effect the code you sent me?
If not then I will go ahead and try it tomorrow. I assume I'll need extra lines of code for the extra fields, so I'm just curious as to where they should be included.
Thanks again. For the heck of it, herss the code:
<form action="mailto: " method="get" name="Contact Us Form" id="formbody" onSubmit="MM_callJS('window.location.href=\'contact_confirm.asp\'')">
<table border="0" cellpadding="1" cellspacing="1" id="formbody">
<tr>
<td align=right><div align="left"><b>FreePhone:</b></div></td>
<td>
<div align="left">1800-923-200 <font color=red>NEW!
24 Hour Order Phoneline Now Open!</font> </div></td>
</tr>
<tr>
<td align=right><div align="left"><b>FreeFax:</b></div></td>
<td><div align="left">1800-923-400</div></td>
</tr>
<tr>
<td align=right valign="top"><div align="left"><b>Post:</b></div></td>
<td><div align="left">Wizard O&E, <br>
FREEPOST, <br>
Sandyford Ind. Estate, <br>
Dublin 18 </div></td>
</tr>
<tr>
<td align=right><div align="left"><strong>E-Mail:</strong></div></td>
<td><div align="left"><a href="mailto: ?subject=Mail%20From%20Site" id="formbody"> </a></div></td>
</tr>
<tr>
<td colspan=2> </td>
</tr>
<tr>
<td colspan=2><div align="left"><a href="catalogue_request.asp" id="formbody">If
you just want to order a FREE catalogue, please click here.</a></div></td>
</tr>
<tr>
<td height="10" colspan=2><div align="left" id="formbody"></div></td>
</tr>
<tr>
<td height="10" colspan=2><div align="left"></div></td>
</tr>
<tr>
<td colspan=2><div align="left"><b>Alternatively, you can send a quick
e-mail to Wizard:</b></div></td>
</tr>
<tr>
<td colspan=2><div align="left"></div></td>
</tr>
<input type="hidden" name="SendRequest" value="true">
<tr>
<td align=right><div align="left">Name:</div></td>
<td><div align="left">
<input name="Name" type="text" onBlur="MM_validateForm('Name','','R');return document.MM_returnValue">
</div></td>
</tr>
<tr>
<td align=right><div align="left">Email:</div></td>
<td><div align="left">
<input name="email" type="text" onBlur="MM_validateForm('email','','RisEmail');return document.MM_returnValue">
</div></td>
</tr>
<tr>
<td align=right><div align="left">Phone:</div></td>
<td><div align="left">
<input name="phone" type="text" onBlur="MM_validateForm('phone','','RisNum');return document.MM_returnValue">
</div></td>
</tr>
<tr>
<td align=right valign=top><div align="left">Message:</div></td>
<td><div align="left">
<textarea name="body" cols=40 rows=7 onBlur="MM_validateForm('body','','R');return document.MM_returnValue"></textarea>
</div></td>
</tr>
<tr>
<td> </td>
<td align=right><input name="submit" type=submit onClick="MM_validateForm('Name','','R','email','','RisEmail','phone','','RisNum','body','','R');return document.MM_returnValue" value="Send E-Mail"></td>
</tr>
</table>
</form>
Replied 21 Sep 2005 11:53:05
21 Sep 2005 11:53:05 Michael Behan replied:
I would make the page that does the emailing a vbscript (so you dont have to translate the code I gave), the other pages being javascript wont be a problem. If you want to have the mailing code on a javascript page put it in
<pre id=code><font face=courier size=2 id=code><script language="vbscript" runat="server"></script></font id=code></pre id=code> rather than <pre id=code><font face=courier size=2 id=code><%%></font id=code></pre id=code>To add other fields to the body of the message it's basically body=Request("something", body=body&Request("something else"
so for that I would create a variabe called body, do the above for adding the bits together and then put
objMessage.TextBody = body
instead of
objMessage.TextBody = Request("comments"
<pre id=code><font face=courier size=2 id=code><script language="vbscript" runat="server"></script></font id=code></pre id=code> rather than <pre id=code><font face=courier size=2 id=code><%%></font id=code></pre id=code>To add other fields to the body of the message it's basically body=Request("something", body=body&Request("something else"
so for that I would create a variabe called body, do the above for adding the bits together and then put
objMessage.TextBody = body
instead of
objMessage.TextBody = Request("comments"