View Full Version : Send ASP email to designated address based on variable
nicky
07-09-2010, 07:43 PM
I'm trying to create this ASP form that grabs the location variable from the URL, and then based on that URL, sends the form submission to the designated email associated with that variable.
Dim here, there, location
If whotoemail = here Then
location = "me@mydomain.com"
ElseIf whotoemail = there Then
location = "you@yourdomain.com"
End If
mail.To = location
When I execute the form, it says:
At least one recipient is required, but none were found.
If anyone could point me in the right direction, I'd appreciate it. Thank you!
Old Pedant
07-09-2010, 07:55 PM
DEBUG time, again.
...
Response.Write "DEBUG location is " & location & "<HR>" & vbNewLine
mail.To = location
...
nicky
07-09-2010, 07:58 PM
So...
If whotoemail = here Then
location = "me@mydomain.com"
Response.Write "Location is " & location & VbCrLf
ElseIf whotoemail = there Then
location = "you@yourdomain.com"
Response.Write "Location is " & location & VbCrLf
End If
mail.To = location
But I don't want the location to actually write
Old Pedant
07-09-2010, 08:49 PM
I know that. You remove the RESPONSE.WRITE after it starts working.
But you put the code in the wrong place.
If whotoemail = here Then
location = "me@mydomain.com"
ElseIf whotoemail = there Then
location = "you@yourdomain.com"
End If
Response.Write "Location is " & location & VbCrLf
mail.To = location
See, my *guess* is that you are never setting the location variable to ANY value.
By the by, another trick/technique to use:
<%
' put this at the VERY TOP of your ASP page:
CONST DODEBUG = True ' change this to false to turn off the debugging output!
... lots of code maybe in here? ...
If whotoemail = here Then
location = "me@mydomain.com"
ElseIf whotoemail = there Then
location = "you@yourdomain.com"
End If
If DODEBUG Then Response.Write "Location is " & location & VbCrLf
mail.To = location
Now you can sprinkle lots of IF DODEBUG THEN lines in your code and easily turn debugging on and off with just a change to the one line at the top.
nicky
07-12-2010, 01:52 PM
This is the message I received:
Location is
CDO.Message.1 error '8004020c'
At least one recipient is required, but none were found.
/send-application.asp, line 41
Line 41 is mail.Send()
Old Pedant
07-12-2010, 07:53 PM
So exactly what I said.
See, my *guess* is that you are never setting the location variable to ANY value.
Clearly *NEITHER* of your "IF" tests are succeeding:
If whotoemail = here Then
location = "me@mydomain.com"
ElseIf whotoemail = there Then
location = "you@yourdomain.com"
End If
Clearly your whotoemail value does not match *either* here or there.
More debugging is in your future.
nicky
07-13-2010, 01:40 PM
I set the location in the URL:
www.mydomain.com/form.asp?location=here
Then in the "whotoemail" field, I grabbed the location's variable. In this case, here.
Then my if/elseif statements... whotoemail = here then email this address. I don't understand why it's not working.
Old Pedant
07-13-2010, 08:34 PM
You *STILL* won't show me your full code so I can *ONLY* make a pure guess.
**GUESS ONLY**
If whotoemail = "here" Then
location = "me@mydomain.com"
ElseIf whotoemail = "there" Then
location = "you@yourdomain.com"
End If
QUOTES around "here" and "there".
But, still, if whotoemail is *neither* of those values, then location will *NOT* be set.
I'm not going to answer again until you show your full code. I can't go on guessing forever.
nicky
07-14-2010, 02:13 PM
Whoo! I worked by adding the double quotations to the location variable! :P Thank you so much! You've been mucho helpful!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.