Hi,
I have a form which has to be sent to one of two different email-addresses.
The "to"-email-address should be taken from a "country"-selection,
the vistor makes.
This part runs actually very well. Unfortunately, the email show as "Country"
the value of the selection and this is the "to"-email-address (vendor). :-(
Where or what do I have to change/add in my coding (see below), that the
submitted email shows as Country the selected Country name instead of the
"to"-emailaddress?
Code of the form "
":
Sendmail code of file "
"
Some details about the Access 2000 DB and the Query:
Select from: qyr_VendorInfo - contains two columns
Column 1: CountryName- 197 Country Names A - Z
Column 2: VendorEmail - shows the "to"-email-address of the responsible HQ
Thanks in advance for you help.
Regards
Lupo WEB Designer & WEB Developer (as per my working contract) and especially ASP Newbie
I have a form which has to be sent to one of two different email-addresses.
The "to"-email-address should be taken from a "country"-selection,
the vistor makes.
This part runs actually very well. Unfortunately, the email show as "Country"
the value of the selection and this is the "to"-email-address (vendor). :-(
Where or what do I have to change/add in my coding (see below), that the
submitted email shows as Country the selected Country name instead of the
"to"-emailaddress?
Code of the form "
Code:
form_in.asp
Code:
<html>
<head><title>Form Page</title></head>
<body>
<form method="post" action="form_out.asp" name="Form">
<table>
<tr>
<td>Contact:</td>
<td><input type="text" name="contact" size="60"></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email" size="60"></td>
</tr>
<tr>
<td>Country</td>
<td>
<select name="vendor" size="1">
<option value="" selected>
----- Please select a country -----</option>
<% @language=javascript %>
<%
var conn=Server.CreateObject("ADODB.Connection");
var rs=Server.CreateObject("ADODB.Recordset");
conn.open("GXBasic");
rs=conn.execute("SELECT * FROM qyr_VendorInfo ORDER BY CountryName ASC");
while (!rs.EOF)
{
Response.write("<option value="+rs("VendorEmail")+"@mydomain.com>"+rs("CountryName")+"</option>"+"\n");
rs.MoveNext();
}
rs.close();
conn.close();
%>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="image" src="submit.gif" value="Submit"> </td>
</tr>
</table>
</form>
</body>
</html>
Sendmail code of file "
Code:
form_out.asp
Code:
<%
Response.Buffer = True
'Dimension variables
Dim strBody 'Holds the email body
Dim objCDOMail 'Holds the mail server object
Dim strMyEmailAddress 'Holds my e-mailaddress
Dim strCCEmailAddress 'Holds cc e-mailaddress
Dim strBCEmailAddress 'Holds bc e-mailaddress
Dim strReturnEmailAddress 'Holds the return e-mail address of the user
strMyEmailAddress = ""
strCCEmailAddress = ""
strBCEmailAddress = ""
'Read in the users e-mail address
strReturnEmailAddress = Request.Form("email")
strMyEmailAddress = Request.Form("Vendor")
'Initialse strBody string with the body of the e-mail
strBody = "Vendor Information<br>"
strBody = strBody & "Company: <b>" & Request.Form("company") & "</b><br>"
strBody = strBody & "Address: <b>" & Request.Form("address") & "</b><br>"
strBody = strBody & "Contact: <b>" & Request.Form("contact") & "</b><br>"
strBody = strBody & "Country: <b>" & Request.Form("Vendor") & "</b><br>"
'Check to see if the user has entered an e-mail address and that it is a valid address
'otherwise set the e-mail address to your own otherwise the e-mail will be rejected
If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then
'Set the return e-mail address to my own
strReturnEmailAddress = strMyEmailAddress
End If
'Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent)
objCDOMail.From = Request.Form("Contact") & " <" & strReturnEmailAddress & ">"
objCDOMail.To = strMyEmailAddress
objCDOMail.Cc = strCCEmailAddress
objCDOMail.Bcc = strBCEmailAddress
objCDOMail.Subject = "Vendor Information"
objCDOMail.BodyFormat = 0
objCDOMail.MailFormat = 0
objCDOMail.Body = strBody
objCDOMail.Importance = 2
objCDOMail.Send
Set objCDOMail = Nothing
%>
<html>
<head><title>Confirmation Page</title></head>
<body>
<p>Thank you <% = Request.Form("contact") %> for your Vendor Information. </p>
</body>
</html>
Some details about the Access 2000 DB and the Query:
Select from: qyr_VendorInfo - contains two columns
Column 1: CountryName- 197 Country Names A - Z
Column 2: VendorEmail - shows the "to"-email-address of the responsible HQ
Thanks in advance for you help.
Regards
Lupo WEB Designer & WEB Developer (as per my working contract) and especially ASP Newbie