|
| |
|
|
John316
Posts: 214 Joined: 9/25/2002 Status: offline
|
email script question - 5/8/2003 19:24:32
All, I have created a contact us web form for users to emailing me there problems. Here is my Question I have a field in my SQL Database called cities. Is there a way to setup a page so that if you are in a city it will email a certain person? Example: If you are from Dallas it will email - admin1@example.com If you are from Houston it will email - admin2@example.com I am including my email script below: <% Dim objNewMail IF Request.Form(" cmdSend" ) = " Send" THEN Set objNewMail = Server.CreateObject(" CDONTS.NewMail" ) objNewMail.From = Request.Form(" From" ) objNewMail.To = Request.Form(" To" ) objNewMail.Subject = Request.Form(" Subject" ) objNewMail.Body = Request.Form(" Message" ) objNewMail.Send Set objNewMail = Nothing Response.Redirect " Thankyou.asp" END IF %> Thanks, John316
< Message edited by john316 -- 5/8/2003 7:36 PM >
|
|
|
|
Jim McShane
Posts: 48 Joined: 8/13/2002 Status: offline
|
RE: email script question - 5/8/2003 21:23:10
all you would have to do is use if then statement for each e-mail address based on the city entered in your submit form... for example: on my jmail contact form i based the e-mail subject on a drop down box on my form... would imagine you could try something similar to this for CDONTS... how many different email addresses do u have to send to... and are you manually coding the addresses or taking from a database?? ' jmail sends mail to customer Set JMail = Server.CreateObject(" JMail.SMTPMail" ) JMail.ServerAddress = " localhost" JMail.Sender = Session(" vc_email_add" ) if Session(" v_category" ) = 1 then JMail.Subject = " Medical Collection Boxes" elseif Session(" v_category" ) = 2 then JMail.Subject = " Miscellaneous Items" elseif Session(" v_category" ) = 3 then JMail.Subject = " Customization Options" elseif Session(" v_category" ) = 4 then JMail.Subject = " Suggestions or Comments" elseif Session(" v_category" ) = 5 then JMail.Subject = " Technical Issues" end if
|
|
|
|
John316
Posts: 214 Joined: 9/25/2002 Status: offline
|
RE: email script question - 5/9/2003 12:39:29
The users email address are in my database and that field is called UserEmailAddress, the cities that the are are in are located in the column called city. I have 16 email address I want them to go to. Admin1@example.com to Admin16@example.com. I just want it so when the user submits a form and he is in Dallas it will send the email to Admin1@example.com and so on. John316
|
|
|
|
rdouglass
Posts: 9280 From: Biddeford, ME USA Status: offline
|
RE: email script question - 5/9/2003 12:58:08
Well, with only 16 addresses, I would tend to use a static list and the CASE statement like above. 16 seems to be a pretty manageable number to me. How are you determining the city? Is it posted from the form? I know you stated that you have a field called " Cities" but how is that related to the problem? Can you just use Request as in: SELECT CASE Request(" cities" ) ???
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
Jim McShane
Posts: 48 Joined: 8/13/2002 Status: offline
|
RE: email script question - 5/9/2003 13:14:29
i agree with rdouglass...just use a drop down box on form with predetermined citys and then use the case statement to send to appropriate e-mail addresses... -jim
|
|
|
|
Jim McShane
Posts: 48 Joined: 8/13/2002 Status: offline
|
RE: email script question - 5/9/2003 13:21:38
another question... did you create this table in your database just to use for this form or is it part of your system. cause if your just making a this table for use on this form then i wouldn' t bother and use static list... but if u plan and using table dynamically then i would reconsider and maybe populate the drop down with the database and retrieve that certain e-mail address based on the drop down value. -jim
|
|
|
|
John316
Posts: 214 Joined: 9/25/2002 Status: offline
|
RE: email script question - 5/11/2003 22:22:19
rdouglass, The cities are predetermined based on the user registration. On our registration form it has them put what city they are in. So now I have created a contact us web form for users to emailing me there problems. I do have one question for you rdouglass on your response you tell me to SELECT CASE myDBCityVariable So here I would put my database name in? OR would it be the column they data is kept under? Thanks for your help, John316
|
|
|
|
John316
Posts: 214 Joined: 9/25/2002 Status: offline
|
RE: email script question - 5/12/2003 14:40:58
I have used spooky login in the past but I am trying to learn some of this for myself. I do have a session. So you are saying I could do something like: SELECT CASE Session(" cities" ) John316
|
|
|
|
John316
Posts: 214 Joined: 9/25/2002 Status: offline
|
RE: email script question - 5/12/2003 17:29:09
rdouglass, It doesn' t work it skips all of your CASE statement and goes right to the else statemen: CASE ELSE sendToVar = " me@myDomain.com" Any idea' s to why? John316
|
|
|
|
rdouglass
Posts: 9280 From: Biddeford, ME USA Status: offline
|
RE: email script question - 5/13/2003 9:22:23
Do you have a valid session? IOW, can you do something like: <% Dim objNewMail, sendToVar response.write Session(" cities" ) SELECT CASE Session(" cities" ) CASE " Dallas" sendToVar = " bgates@microsoft.com" Case " Houston sendToVar = " sjobs@apple.com" ..... Then check to see that the session is writeen to the screen. Without a valid session, you' ll always go to the CASE ELSE line. Any help there?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
John316
Posts: 214 Joined: 9/25/2002 Status: offline
|
RE: email script question - 5/16/2003 3:21:45
rdouglass, How can I check to see if I hae a valid session? John316
|
|
|
|
rdouglass
Posts: 9280 From: Biddeford, ME USA Status: offline
|
RE: email script question - 5/16/2003 8:52:29
<%=response.write Session(" cities" )%> That should display what' s in the session " cities" . If nothing shows in the browser, you don' t have anything in the session (it doesn' t exist...)
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
John316
Posts: 214 Joined: 9/25/2002 Status: offline
|
RE: email script question - 5/19/2003 20:21:03
rdouglass, When I add the code: <%=response.write Session(" cities" )%> I see Dallas in the upper right hand corner. So I am not sure why it is going to the ELSE statement first? Do you have a clue? John316
|
|
|
|
Cookie
Posts: 297 Joined: 2/7/2002 From: UK Status: offline
|
RE: email script question - 5/20/2003 5:11:00
Surely a simpler solution would be to to have the dropdown with all the cities and the value it submits would be the email address it needs to go to. Then.... on the email form you just request that value. Dave
|
|
|
|
John316
Posts: 214 Joined: 9/25/2002 Status: offline
|
RE: email script question - 5/23/2003 17:19:24
Spooky & Cookie, I did a response.write Session(" cities" ) and it looks like the case statement is working. How do I get the email address to show up in a text box? This is what I have and I know it is not right, not sure what the value should be in a Case Statement: <tr> <td valign=" top" align=" left" ><b>To Address:</b></td> <td valign=" top" align=" left" > <input type=" text" name=" To" size=" 65" tabindex=" 2" value=" sendToVar" > </td> Thanks, John316
|
|
|
|
John316
Posts: 214 Joined: 9/25/2002 Status: offline
|
RE: email script question - 5/25/2003 17:02:21
at the top of the page and the form is at the bottom of the page John316
|
|
|
|
John316
Posts: 214 Joined: 9/25/2002 Status: offline
|
RE: email script question - 5/27/2003 11:28:37
Thanks Spooky it worked John316
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|