Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDOMail > ListOfValue > different email recipient

Status
Not open for further replies.

Lupo

Programmer
Oct 29, 2001
31
CH
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 "
Code:
form_in.asp
":

Code:
<html>
<head><title>Form Page</title></head>
<body>
<form method=&quot;post&quot; action=&quot;form_out.asp&quot; name=&quot;Form&quot;>
 <table>
   <tr>
     <td>Contact:</td>
     <td><input type=&quot;text&quot; name=&quot;contact&quot; size=&quot;60&quot;></td>
   </tr>
   <tr>
     <td>Email:</td>
     <td><input type=&quot;text&quot; name=&quot;email&quot; size=&quot;60&quot;></td>
   </tr>   
   <tr>
     <td>Country</td>
     <td>
     <select name=&quot;vendor&quot; size=&quot;1&quot;>
        <option value=&quot;&quot; selected>
         ----- Please select a country  -----</option>
        <% @language=javascript %>
        <%
	var conn=Server.CreateObject(&quot;ADODB.Connection&quot;);
	var rs=Server.CreateObject(&quot;ADODB.Recordset&quot;);
	conn.open(&quot;GXBasic&quot;);
	rs=conn.execute(&quot;SELECT * FROM qyr_VendorInfo ORDER BY CountryName ASC&quot;);
	while (!rs.EOF)
	{
	Response.write(&quot;<option value=&quot;+rs(&quot;VendorEmail&quot;)+&quot;@mydomain.com>&quot;+rs(&quot;CountryName&quot;)+&quot;</option>&quot;+&quot;\n&quot;);
	rs.MoveNext();
	}
	rs.close();
	conn.close();
	%>
     </select>
     </td>
   </tr>
   <tr>
     <td></td>
     <td><input type=&quot;image&quot; src=&quot;submit.gif&quot; value=&quot;Submit&quot;> </td>
   </tr>
 </table>
</form>

</body>
</html>

Sendmail code of file &quot;
Code:
form_out.asp
&quot;

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 = &quot;&quot;
strCCEmailAddress = &quot;&quot;
strBCEmailAddress = &quot;&quot;

'Read in the users e-mail address
strReturnEmailAddress = Request.Form(&quot;email&quot;)
strMyEmailAddress = Request.Form(&quot;Vendor&quot;)


'Initialse strBody string with the body of the e-mail
strBody = &quot;Vendor Information<br>&quot;
strBody = strBody & &quot;Company:   <b>&quot; & Request.Form(&quot;company&quot;) & &quot;</b><br>&quot;
strBody = strBody & &quot;Address:   <b>&quot; & Request.Form(&quot;address&quot;) & &quot;</b><br>&quot;
strBody = strBody & &quot;Contact:   <b>&quot; & Request.Form(&quot;contact&quot;) & &quot;</b><br>&quot;
strBody = strBody & &quot;Country:   <b>&quot; & Request.Form(&quot;Vendor&quot;) & &quot;</b><br>&quot;

'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, &quot; &quot;) = 0 OR InStr(1, strReturnEmailAddress, &quot;@&quot;, 1) < 2 OR InStrRev(strReturnEmailAddress, &quot;.&quot;) < InStr(1, strReturnEmailAddress, &quot;@&quot;, 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(&quot;CDONTS.NewMail&quot;)

'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(&quot;Contact&quot;) & &quot; <&quot; & strReturnEmailAddress & &quot;>&quot;

objCDOMail.To = strMyEmailAddress
objCDOMail.Cc = strCCEmailAddress
objCDOMail.Bcc = strBCEmailAddress
objCDOMail.Subject = &quot;Vendor Information&quot;
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(&quot;contact&quot;) %> 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 &quot;to&quot;-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 :)
 
Hi, help!! Looking forward to get a tip to this problem. Please help!! Thanks in advance and regards. Lupo
WEB Designer & WEB Developer (as per my working contract) and especially ASP Newbie :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top