contesa
asked on
Form Mail
Hello,
I am working on trying to add a form mail to my website. I have a list menu in my form. I would like to be able to submit the request to the individual selected in my list menu. Therefore, my receipient field has to be dynamic depending on the selection. How can I accomplish this?
I am working on trying to add a form mail to my website. I have a list menu in my form. I would like to be able to submit the request to the individual selected in my list menu. Therefore, my receipient field has to be dynamic depending on the selection. How can I accomplish this?
ASKER
Thank you for responding so quickly. I tested the code; however, it launches my email client in order to send the message. In addition, it doesn't automatically include the sender's email address in the to fiield of the message. Is there another way where either the email could be automatically added to the to: field in the message or completely avoid launching my email client.
I must inform you that I am new to programming so I will need to see examples of code.
I must inform you that I am new to programming so I will need to see examples of code.
contesa,
Are you using any web technology like PHP, ASP, .NET, JSP, etc or just plain on HTML/Javascript?
Are you using any web technology like PHP, ASP, .NET, JSP, etc or just plain on HTML/Javascript?
ASKER
Hi sc0rp10n,
No I am currently not using any web technology. I am very new to this field as you can tell. My web server is a Windows 2000 server. My network manager set up the server and I am not sure what's loaded on the server. However, I'm sure that I can get him to load whatever I need.
I am just using HTML/Javascript at the current time.
No I am currently not using any web technology. I am very new to this field as you can tell. My web server is a Windows 2000 server. My network manager set up the server and I am not sure what's loaded on the server. However, I'm sure that I can get him to load whatever I need.
I am just using HTML/Javascript at the current time.
ASKER
Below is the code for my form. It's a simple form. However, I would like to eliminate the script I'm using for sending mail because it launches the email client. As you can see, there is a drop down list. When the user makes a selection and fills out the form, I want the email to be sent to that person.
I also want to be able to automatically generate a service tracking number. In the future, I would like to dump this information into a database. But not right now. I just want to get these two features working as soon as possible. I don't have anything included for form action because I don't know which scripting language would be best. I would like the script to process both the send mail and the automatic numbering. Is that possible? Again, I'm a newbie.. :-)
I am running on a Windows 2000 Server/IIS. Not sure what my network manager has installed on the server. But he will install whatever I need.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function sendMail()
{
var theForm = document.myForm;
var recip = theForm.mailList.options[t heForm.mai lList.sele ctedIndex] .text;
theForm.action = "mailto:"+recip;
alert('will mail to: '+recip);
return true;
}
</script>
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
color: #000000;
font-weight: bold;
}
-->
</style>
</head>
<body><form action="" method="post" enctype="multipart/form-da ta" name="myForm" onSubmit="return sendMail();">
<table width="500" border="1" align="center">
<tr>
<td colspan="5"><table width="100%" border="0" align="center">
<tr>
<td colspan="2"><div align="center" class="style1">Information Technology Management & Support<br>
SERVICE REQUEST </div></td>
</tr>
<tr>
<td width="18%">Request No.</td>
<td width="82%"> </td>
</tr>
</table></td>
</tr>
<tr>
<td width="121"><div align="center">DATE</div>< /td>
<td width="152"><div align="center">REQUESTOR</ div></td>
<td width="100"><div align="center">BUREAU</div ></td>
<td width="99" colspan="2"><div align="center">PHONE # </div></td>
</tr>
<tr>
<td><div align="center">
<input name="date" type="text" id="date" size="20" maxlength="20">
</div></td>
<td><div align="center">
<input name="requestor" type="text" id="requestor" size="20" maxlength="20">
</div></td>
<td><div align="center">
<select name="mailList">
<option value="kathy.coates@njdge. org">ADM</ option>
<option value="dan.kelly@njdge.org ">CEB/NJSP </option>
<option value="paul.kuras@njdge.or g">CIU</op tion>
<option value="ted.grove">CJ</opti on>
<option value="mike.romano@njdge.o rg">CLS</o ption>
<option value="jean.escarpeta@njdg e.org">ELS </option>
<option value="rich.handzo@njdge.o rg">REB</o ption>
<option value="debbie.algor@njdge. org">REC/I D</option>
<option value="al.white@njdge.org" >SILS</opt ion>
<option value="rich.williamson@njd ge.org">TS B</option>
<option value="willie.johnson@njdg e.org">TES T</option>
<option value="jon.rocque@njdge.or g">TEST2</ option>
</select>
</div></td>
<td colspan="2"><div align="center">
<input name="phone_no" type="text" id="phone_no" size="10" maxlength="10">
</div></td>
</tr>
<tr>
<td colspan="5"><div align="center"><strong>SER VICES REQUESTED </strong></div></td>
</tr>
<tr>
<td colspan="5"><div align="center">
<textarea name="services_requested" cols="60" id="services_requested"></ textarea>
</div></td>
</tr>
<tr>
<td colspan="5"><div align="center"><strong>JUS TIFICATION </strong>< /div></td>
</tr>
<tr>
<td colspan="5"><div align="center">
<textarea name="justification" cols="60" id="justification"></texta rea>
</div></td>
</tr>
<tr>
<td colspan="5"><div align="center">
<input type="submit" value="send">
</div></td>
</tr>
</table>
</form>
</body>
</html>
I also want to be able to automatically generate a service tracking number. In the future, I would like to dump this information into a database. But not right now. I just want to get these two features working as soon as possible. I don't have anything included for form action because I don't know which scripting language would be best. I would like the script to process both the send mail and the automatic numbering. Is that possible? Again, I'm a newbie.. :-)
I am running on a Windows 2000 Server/IIS. Not sure what my network manager has installed on the server. But he will install whatever I need.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function sendMail()
{
var theForm = document.myForm;
var recip = theForm.mailList.options[t
theForm.action = "mailto:"+recip;
alert('will mail to: '+recip);
return true;
}
</script>
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
color: #000000;
font-weight: bold;
}
-->
</style>
</head>
<body><form action="" method="post" enctype="multipart/form-da
<table width="500" border="1" align="center">
<tr>
<td colspan="5"><table width="100%" border="0" align="center">
<tr>
<td colspan="2"><div align="center" class="style1">Information
SERVICE REQUEST </div></td>
</tr>
<tr>
<td width="18%">Request No.</td>
<td width="82%"> </td>
</tr>
</table></td>
</tr>
<tr>
<td width="121"><div align="center">DATE</div><
<td width="152"><div align="center">REQUESTOR</
<td width="100"><div align="center">BUREAU</div
<td width="99" colspan="2"><div align="center">PHONE # </div></td>
</tr>
<tr>
<td><div align="center">
<input name="date" type="text" id="date" size="20" maxlength="20">
</div></td>
<td><div align="center">
<input name="requestor" type="text" id="requestor" size="20" maxlength="20">
</div></td>
<td><div align="center">
<select name="mailList">
<option value="kathy.coates@njdge.
<option value="dan.kelly@njdge.org
<option value="paul.kuras@njdge.or
<option value="ted.grove">CJ</opti
<option value="mike.romano@njdge.o
<option value="jean.escarpeta@njdg
<option value="rich.handzo@njdge.o
<option value="debbie.algor@njdge.
<option value="al.white@njdge.org"
<option value="rich.williamson@njd
<option value="willie.johnson@njdg
<option value="jon.rocque@njdge.or
</select>
</div></td>
<td colspan="2"><div align="center">
<input name="phone_no" type="text" id="phone_no" size="10" maxlength="10">
</div></td>
</tr>
<tr>
<td colspan="5"><div align="center"><strong>SER
</tr>
<tr>
<td colspan="5"><div align="center">
<textarea name="services_requested" cols="60" id="services_requested"></
</div></td>
</tr>
<tr>
<td colspan="5"><div align="center"><strong>JUS
</tr>
<tr>
<td colspan="5"><div align="center">
<textarea name="justification" cols="60" id="justification"></texta
</div></td>
</tr>
<tr>
<td colspan="5"><div align="center">
<input type="submit" value="send">
</div></td>
</tr>
</table>
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Scorpion,
Thank you very much for taking the time to edit my code. My network manager is not in the office today so I can't test the code until tomorrow.
I will give you an update of my results tomorrow.
Thank you again.
Thank you very much for taking the time to edit my code. My network manager is not in the office today so I can't test the code until tomorrow.
I will give you an update of my results tomorrow.
Thank you again.
ASKER
Scorpion,
I setup IIS on my personal pc for testing purposes. I wanted to test the code before my network manager returns tomorrow.
I am receiving the following error message:
Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/sendrequest.asp, line 106, column 12
dim msgBody = "The following service request has been submitted: " & vbCrLf & vbCrLf
-----------^
I looked at the code and didn't find any misspellings or missing quotes. What am I missing? Any ideas?
I setup IIS on my personal pc for testing purposes. I wanted to test the code before my network manager returns tomorrow.
I am receiving the following error message:
Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/sendrequest.asp, line 106, column 12
dim msgBody = "The following service request has been submitted: " & vbCrLf & vbCrLf
-----------^
I looked at the code and didn't find any misspellings or missing quotes. What am I missing? Any ideas?
ASKER
Scorpion,
I fixed the above code error by splitting up
dim msgBody = "The following service request has been submitted: " & vbCrLf & vbCrLf
into two lines.
dim msgBody
msgBody = "The following service request has been submitted: " & vbCrLf & vbCrLf
Now, I get the following when clicking send:
Mail sent to:
Nothing else displays --only that line of text. I'm testing the script by entering my own email address. I haven't received any messages.
I'm using IIS on my personal Win XP pc for testing purposes. I installed and registered cdonts.dll. Am I missing something else?
I appreciate any help you can provide.
Thank you.
I fixed the above code error by splitting up
dim msgBody = "The following service request has been submitted: " & vbCrLf & vbCrLf
into two lines.
dim msgBody
msgBody = "The following service request has been submitted: " & vbCrLf & vbCrLf
Now, I get the following when clicking send:
Mail sent to:
Nothing else displays --only that line of text. I'm testing the script by entering my own email address. I haven't received any messages.
I'm using IIS on my personal Win XP pc for testing purposes. I installed and registered cdonts.dll. Am I missing something else?
I appreciate any help you can provide.
Thank you.
Hi contesa,
Try to save this the following as an asp file and access it via the browser. Make sure you add your email address before you access it.
This is a simple asp mail using CDONTS. If the mail is sent, then you should see the message "Your mail has been sent. "
Hope this works. Lets start from here, to make sure all is working good.
-- start asp code --
<html>
<head>
<title>Test email</title>
</head>
<body>
<%
Set objMail = Server.CreateObject("CDONT S.NewMail" )
objMail.From = "PutYourEmailAddressHere"
objMail.To = "PutYourEmailAddressHere"
objMail.Subject="Test Email"
objMail.Body = "Test Email"
objMail.Send
Set objMail = nothing
%>
<p><strong>Your mail has been sent. </strong></p>
</body>
</html>
-- end asp code --
Try to save this the following as an asp file and access it via the browser. Make sure you add your email address before you access it.
This is a simple asp mail using CDONTS. If the mail is sent, then you should see the message "Your mail has been sent. "
Hope this works. Lets start from here, to make sure all is working good.
-- start asp code --
<html>
<head>
<title>Test email</title>
</head>
<body>
<%
Set objMail = Server.CreateObject("CDONT
objMail.From = "PutYourEmailAddressHere"
objMail.To = "PutYourEmailAddressHere"
objMail.Subject="Test Email"
objMail.Body = "Test Email"
objMail.Send
Set objMail = nothing
%>
<p><strong>Your mail has been sent. </strong></p>
</body>
</html>
-- end asp code --
ASKER
Scorpion,
The above script does work. I received messages when viewing the page in the browser. But I did notice that it didn't send a message each time I viewed the page, it's intermittent.
The above script does work. I received messages when viewing the page in the browser. But I did notice that it didn't send a message each time I viewed the page, it's intermittent.
ASKER
Good morning Scorpion,
Looks like my IIS server just needed a little warming up....the messages are coming through about a minute after I view the page.
So the script works!
Looks like my IIS server just needed a little warming up....the messages are coming through about a minute after I view the page.
So the script works!
Good morning Contesa,
Well, that means that the mail server/iis + everything else is working perfectly fine. Its just a matter of trying to get the form variables rite.
Try to change the METHOD value from "POST" to "GET", then change "Request.Form" to just "Request".
This should help a bit.
Well, that means that the mail server/iis + everything else is working perfectly fine. Its just a matter of trying to get the form variables rite.
Try to change the METHOD value from "POST" to "GET", then change "Request.Form" to just "Request".
This should help a bit.
btw, "Request" should work, but if it doesn't try "Request.QueryString".
make sure the item is present in the brackets. i.e
Request("requestor")
or
Request.QueryString("reque stor")
make sure the item is present in the brackets. i.e
Request("requestor")
or
Request.QueryString("reque
ASKER
Hi Scorpion,
It didn't work with either Request or Request.QueryString...I'm still getting the exact same response (Mail sent to: )
I did change it from post to get as well.
Any other suggestions?
Again, thank you very much for all of your help.
It didn't work with either Request or Request.QueryString...I'm still getting the exact same response (Mail sent to: )
I did change it from post to get as well.
Any other suggestions?
Again, thank you very much for all of your help.
hy contesa,
quick question, does your mail server relay emails. as in the mails that you are sending, do they have internal email addresses.
Also, if you can post your code, i'll have a go at it myself and will let you know. But theoritically, it should've worked as i've used that same code myself a while back.
quick question, does your mail server relay emails. as in the mails that you are sending, do they have internal email addresses.
Also, if you can post your code, i'll have a go at it myself and will let you know. But theoritically, it should've worked as i've used that same code myself a while back.
ASKER
Hi Scorpion,
Here is the code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>ITMS Service Request</title>
<%
response.buffer=true
Func = Request("Func")
if isempty(Func) then
Func = 1
end if
Select case Func
case 1
%>
<style type="text/css">
<!--
.style1 {
color: #000000;
font-weight: bold;
}
-->
</style>
</head>
<body><form action="sendrequest.asp?fu nc=2" method="get" enctype="multipart/form-da ta" name="myForm">
<table width="500" border="1" align="center">
<tr>
<td colspan="5"><table width="100%" border="0" align="center">
<tr>
<td colspan="2"><div align="center" class="style1">Information Technology Management & Support<br>
SERVICE REQUEST </div></td>
</tr>
<tr>
<td width="18%">Request No.</td>
<td width="82%"> </td>
</tr>
</table></td>
</tr>
<tr>
<td width="121"><div align="center">DATE</div>< /td>
<td width="152"><div align="center">REQUESTOR</ div></td>
<td width="100"><div align="center">BUREAU</div ></td>
<td width="99" colspan="2"><div align="center">PHONE # </div></td>
</tr>
<tr>
<td><div align="center">
<input name="date" type="text" id="date" size="20" maxlength="20">
</div></td>
<td><div align="center">
<input name="requestor" type="text" id="requestor" size="20" maxlength="30">
</div></td>
<td><div align="center">
<select name="mailList">
<option value="kathy.coates@njdge. org">ADM</ option>
<option value="dan.kelly@njdge.org ">CEB/NJSP </option>
<option value="paul.kuras@njdge.or g">CIU</op tion>
<option value="ted.grove">CJ</opti on>
<option value="mike.romano@njdge.o rg">CLS</o ption>
<option value="jean.escarpeta@njdg e.org">ELS </option>
<option value="rich.handzo@njdge.o rg">REB</o ption>
<option value="debbie.algor@njdge. org">REC/I D</option>
<option value="al.white@njdge.org" >SILS</opt ion>
<option value="rich.williamson@njd ge.org">TS B</option>
<option value="willie.johnson@njdg e.org">wil lie.johnso n@njdge.or g</option>
<option value="jon.rocque@njdge.or g">TEST2</ option>
</select>
</div></td>
<td colspan="2"><div align="center">
<input name="phone_no" type="text" id="phone_no" size="10" maxlength="10">
</div></td>
</tr>
<tr>
<td colspan="5"><div align="center"><strong>SER VICES REQUESTED </strong></div></td>
</tr>
<tr>
<td colspan="5"><div align="center">
<textarea name="services_requested" cols="60" id="services_requested"></ textarea>
</div></td>
</tr>
<tr>
<td colspan="5"><div align="center"><strong>JUS TIFICATION </strong>< /div></td>
</tr>
<tr>
<td colspan="5"><div align="center">
<textarea name="justification" cols="60" id="justification"></texta rea>
</div></td>
</tr>
<tr>
<td colspan="5"><div align="center">
<input type="submit" value="send">
</div></td>
</tr>
</table>
</form>
<%
case 2
' CDO mail object
Set objCDOMail = Server.CreateObject("CDONT S.NewMail" )
dim msgBody
msgBody = "The following service request has been submitted: " & vbCrLf & vbCrLf
msgBody = msgBody & "Date: " & Request.QueryString("date" ) & vbCrLf
msgBody = msgBody & "Requestor: " & Request.QueryString("reque stor") & vbCrLf
msgBody = msgBody & "Phone number: " & Request.QueryString("phone _no") & vbCrLf
msgBody = msgBody & "Services request: " & Request.QueryString("servi ces_reques ted") & vbCrLf
msgBody = msgBody & "Justification: " & Request.QueryString("justi fication") & vbCrLf
'msgBody = msgBody & "Date: " & Request.Form("") & vbCrLf
' CDO mail setttings
with objCDOMail
.From = Request.QueryString("reque stor")
.To = Request.QueryString("mailL ist")
'.Cc = strCC
.Subject = "Service Request"
.Body = "The following service request has been submitted: " & vbCrLf
.MailFormat = 0 ' HTML format
.Send
end with
' destroy object, free memory
set objCDOMail = nothing
Response.Write "Mail Sent to: <b>" & Request.QueryString("mailL ist") & "</b>"
Response.Write ""
end select
%>
</body>
</html>
As you can see the last test I ran was with Request.QueryString. I'm not quite sure about your relay emails question. I am testing this on my personal WIN XP pc, I set up IIS on the pc. I haven't changed any of the settings.
Hope this helps....
Again, thank you.
Here is the code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>ITMS Service Request</title>
<%
response.buffer=true
Func = Request("Func")
if isempty(Func) then
Func = 1
end if
Select case Func
case 1
%>
<style type="text/css">
<!--
.style1 {
color: #000000;
font-weight: bold;
}
-->
</style>
</head>
<body><form action="sendrequest.asp?fu
<table width="500" border="1" align="center">
<tr>
<td colspan="5"><table width="100%" border="0" align="center">
<tr>
<td colspan="2"><div align="center" class="style1">Information
SERVICE REQUEST </div></td>
</tr>
<tr>
<td width="18%">Request No.</td>
<td width="82%"> </td>
</tr>
</table></td>
</tr>
<tr>
<td width="121"><div align="center">DATE</div><
<td width="152"><div align="center">REQUESTOR</
<td width="100"><div align="center">BUREAU</div
<td width="99" colspan="2"><div align="center">PHONE # </div></td>
</tr>
<tr>
<td><div align="center">
<input name="date" type="text" id="date" size="20" maxlength="20">
</div></td>
<td><div align="center">
<input name="requestor" type="text" id="requestor" size="20" maxlength="30">
</div></td>
<td><div align="center">
<select name="mailList">
<option value="kathy.coates@njdge.
<option value="dan.kelly@njdge.org
<option value="paul.kuras@njdge.or
<option value="ted.grove">CJ</opti
<option value="mike.romano@njdge.o
<option value="jean.escarpeta@njdg
<option value="rich.handzo@njdge.o
<option value="debbie.algor@njdge.
<option value="al.white@njdge.org"
<option value="rich.williamson@njd
<option value="willie.johnson@njdg
<option value="jon.rocque@njdge.or
</select>
</div></td>
<td colspan="2"><div align="center">
<input name="phone_no" type="text" id="phone_no" size="10" maxlength="10">
</div></td>
</tr>
<tr>
<td colspan="5"><div align="center"><strong>SER
</tr>
<tr>
<td colspan="5"><div align="center">
<textarea name="services_requested" cols="60" id="services_requested"></
</div></td>
</tr>
<tr>
<td colspan="5"><div align="center"><strong>JUS
</tr>
<tr>
<td colspan="5"><div align="center">
<textarea name="justification" cols="60" id="justification"></texta
</div></td>
</tr>
<tr>
<td colspan="5"><div align="center">
<input type="submit" value="send">
</div></td>
</tr>
</table>
</form>
<%
case 2
' CDO mail object
Set objCDOMail = Server.CreateObject("CDONT
dim msgBody
msgBody = "The following service request has been submitted: " & vbCrLf & vbCrLf
msgBody = msgBody & "Date: " & Request.QueryString("date"
msgBody = msgBody & "Requestor: " & Request.QueryString("reque
msgBody = msgBody & "Phone number: " & Request.QueryString("phone
msgBody = msgBody & "Services request: " & Request.QueryString("servi
msgBody = msgBody & "Justification: " & Request.QueryString("justi
'msgBody = msgBody & "Date: " & Request.Form("") & vbCrLf
' CDO mail setttings
with objCDOMail
.From = Request.QueryString("reque
.To = Request.QueryString("mailL
'.Cc = strCC
.Subject = "Service Request"
.Body = "The following service request has been submitted: " & vbCrLf
.MailFormat = 0 ' HTML format
.Send
end with
' destroy object, free memory
set objCDOMail = nothing
Response.Write "Mail Sent to: <b>" & Request.QueryString("mailL
Response.Write ""
end select
%>
</body>
</html>
As you can see the last test I ran was with Request.QueryString. I'm not quite sure about your relay emails question. I am testing this on my personal WIN XP pc, I set up IIS on the pc. I haven't changed any of the settings.
Hope this helps....
Again, thank you.
ASKER
Hi Scorprion,
I want to award you some points for all of your help. I rewrote some of your script and it works now. How do I award the points?
I want to award you some points for all of your help. I rewrote some of your script and it works now. How do I award the points?
hy contesa,
congratulations on solving it. I'm sorry i wasn't at work for the past few days and I couldn't check my mail.
anyhoo, try the following link: https://www.experts-exchange.com/Community_Support/help.jsp#hi68
Basically there will be an accept button near a solution. you should just click that.
sc0rp
congratulations on solving it. I'm sorry i wasn't at work for the past few days and I couldn't check my mail.
anyhoo, try the following link: https://www.experts-exchange.com/Community_Support/help.jsp#hi68
Basically there will be an accept button near a solution. you should just click that.
sc0rp
ASKER
Scorpion,
Thanks for getting me started in the right direction. I really appreciate all of your help. On to my next dilemma!
Thanks for getting me started in the right direction. I really appreciate all of your help. On to my next dilemma!
thx contesa,
glad to have showed you the way.
glad to have showed you the way.
In your HEAD:
=========
<script>
function sendMail()
{
var theForm = document.myForm;
var recip = theForm.mailList.options[t
theForm.action = "mailto:"+recip;
alert('will mail to: '+recip);
return true;
}
</script>
=========
in your BODY:
=========
<form name="myForm" onSubmit="return sendMail();">
<select name="mailList">
<option>joe@someone.com</o
<option>frank@someone.com<
<option>mary@someone.com</
</select>
<input type="submit" value="send">
</form>
-hth
monolith