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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email using ASP

Status
Not open for further replies.

tforr

Programmer
Aug 14, 2003
181
GB
Hi,

I have recently created an ASP page on my website that allows my browsers to email me and my team directly from that page. I have a Name field, email_address field and message text area.

This is working fine but I would like to add some more functionality. I would like to add a combo box that lists 3 area of the business I work in (Support,Sales and Marketing. This will give my browsers the chance to send the email to a specific deaprtment. Can this be done? If so can I have some help.

Thanks and kind regards,

Tom.
 
You could have a dropdown that has the relevant dept/email details so when someone hits send it uses the correct address.

Are you just using Mailto, CDO, AspMail??

Cheech

[Peace][Pipe]
 
Hi Cheech,

Im using CDO.

Would it be possible for you to take me through this then if you have time.

Thanks for the quick reply,

Tom
 
OK

First page has a form with Name field, email_address dropdown and message text area.

The menu should be something like:
Code:
<select name=&quot;select&quot;>
    <option value=&quot;Support@yourcomp.com&quot;>Support</option>
    <option value=&quot;Sales@yourcomp.com&quot;>Sales</option>
    <option value=&quot;Marketing@yourcomp.com&quot;>Marketing</option>
  </select>

The forms action should be your cdo page.

Now your cdo page just needs to grab the form data and populate the email with the email addy to send to from the menu

(if that is unclear post me the cdo page and I will see if I can help from there)

Cheech

[Peace][Pipe]
 
I'm using Dreamweaver MX so I would like to stick to this program.

My code is displayed below.

feedback1.asp

<% @language=&quot;VBSCRIPT&quot; %>
<%


Set ObjMail = Server.CreateObject(&quot;CDO.Message&quot;)

objMail.Configuration.Fields(&quot; = 2
objMail.Configuration.Fields(&quot; = &quot;127.0.0.1&quot;

objMail.Configuration.Fields.Update()

objMail.From = request.form(&quot;yourmail&quot;)
objMail.To = &quot;tom@westerbysystems.com&quot;
objMail.Cc = &quot;gursh@westerbysystems.com&quot;

objMail.Subject = &quot;Sending email from a form&quot;
objMail.HTMLBody = request.form(&quot;message&quot;)

objMail.Send()

Response.Write(&quot;Your e-mail has been sent&quot;)

Set ObjMail = Nothing


%>

I have another file called feedback1.htm. This is the page which displays the fields that need input from the browser.
A simplified layout is below.

<html>
<head>
<title>feedback1 form</title>
<body>

<form name=&quot;feedback1&quot; method=&quot;post&quot; action=&quot;feedback1.asp&quot;>

Your Name <input type=&quot;text&quot; name=&quot;yourname&quot; size=&quot;50&quot;>
<br>
Your E-mail Address <input type=&quot;text&quot; name=&quot;yourmail&quot; size=&quot;50&quot;>
<br>
Your Message <textarea name=&quot;message&quot; cols=&quot;43&quot; rows=&quot;5&quot;></textarea>
<br>
<input type=&quot;reset&quot; name=&quot;Reset&quot; value=&quot;Reset&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
<br>
All fields are required

</form>

</body>
</html>

It is this page that I wish to put a list box for the brwoser to chhose from.

Hope this helps, Enjoy.

Tom.........
 
change this line:

objMail.To = &quot;tom@westerbysystems.com&quot;

to

objMail.To = Request.Form(&quot;mySelectName&quot;)

and add a select menu called mySelectName and with your different email addresses as the values (as Cheech suggested).

HTH
Simon
 
New pages..


Code:
==============================================
feedback1.asp
==============================================
<% @language=&quot;VBSCRIPT&quot; %>
<%


Set ObjMail = Server.CreateObject(&quot;CDO.Message&quot;)

objMail.Configuration.Fields(&quot;[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusin...;)[/URL] = 2 
objMail.Configuration.Fields(&quot;[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserv...;)[/URL] = &quot;127.0.0.1&quot;

objMail.Configuration.Fields.Update()

objMail.From = request.form(&quot;yourmail&quot;) 
objMail.To = request.form(&quot;selEmail&quot;) 
objMail.Cc = &quot;gursh@westerbysystems.com&quot;

objMail.Subject = &quot;Sending email from a form&quot; 
objMail.HTMLBody = request.form(&quot;message&quot;)

objMail.Send()

Response.Write(&quot;Your e-mail has been sent&quot;)

Set ObjMail = Nothing


%>
=============================================

feedback1.htm
=============================================
<html>
<head>
<title>feedback1 form</title>
<body>

<form name=&quot;feedback1&quot; method=&quot;post&quot; action=&quot;feedback1.asp&quot;>

  <p>Your Name 
    <input type=&quot;text&quot; name=&quot;yourname&quot; size=&quot;50&quot;>
    <br>
Your E-mail Address 
<input type=&quot;text&quot; name=&quot;yourmail&quot; size=&quot;50&quot;>
</p>
  <p>Interested in 
    <select name=&quot;selEmail&quot; id=&quot;selEmail&quot;>
      <option value=&quot;Support@yourcomp.com&quot;>Support</option>
      <option value=&quot;Sales@yourcomp.com&quot;>Sales</option>
      <option value=&quot;Marketing@yourcomp.com&quot;>Marketing</option>
    </select>
    <br>
  Your Message 
    <textarea name=&quot;message&quot; cols=&quot;43&quot; rows=&quot;5&quot;></textarea>
    <br>
    <input type=&quot;reset&quot; name=&quot;Reset&quot; value=&quot;Reset&quot;>
    <input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
    <br> 
  All fields are required
  
</p>
</form>

</body>
</html>

Now all you gotta do is make it look pretty

Cheech

[Peace][Pipe]
 
Thank you very much. Its working now. I would like to however send the browser to a new page as soon as they have hit submit. I have Response.Write(&quot;Your e-mail has been sent&quot; but I would like to have an actual page so I can place the company banner on the top of the page and automatically direct the user back to my index.asp page.

Cheers,

Tom.
 


The code you need would be

Response.Redirect &quot;index.asp&quot;

but you cannot write anything to the page before a redirect so need to remove

Response.Write(&quot;Your e-mail has been sent&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top