PDA

View Full Version : asp and email question


kovalik
09-09-2002, 04:35 PM
I have a recipe site that uses asp. I want my visitors to be able to "email this recipe to a friend" through a button located on the recipe page. I tried using Javascript but it couldn't handle the specific recipe IDs associated with the asp. The script obviously needs to be server-side.

Here is a sample page:

http://www.recipesplus.ca/recipe.asp?recipeID=47

I'm not sure where to start on this one. I'd be very grateful if someone could point me in the right direction.

Thanks for your time,

kovalik:confused:

Morgoth
09-09-2002, 05:28 PM
first off, do you have ASP support and an SMTP server?

If you do not have either of them, then you might need to get them or try a differnt server side langauge.

kovalik
09-09-2002, 05:30 PM
Yes to both.

Thanks

Morgoth
09-09-2002, 05:31 PM
when you have that sorted out, and you find out that you do have an smtp server and run asp, then it would be good to see some asp code of what the resipes look like.

Because it almost looks like you could just send them a string full of the values that are already on the page.

Morgoth
09-09-2002, 05:41 PM
Now I suppose you want to write it all out with normal text, not HTML.
What you want to do is something like this.


IntNumberOfTomatos = 14
IntNUmberOfCarrots = 2000039484
String = "Stuff in Da Food:" & vbcrlf & vbcrlf & IntNumberOfTomatos & " Tomatos" & vbcrlf & IntNumberOfCarrots & " Carrots" & vbcrlf & vbcrlf & vbcrlf & "Thank you."
Response.Write String


It will look like this:
______________________
Stuff in Da Food:

14 Tomatos"
2000039484 Carrots


Thank you.
_______________________

Now what you do is instead of writing it to the screen. You will send it with an e-mail.
To do that, you will need CDONTS.
http://quadcomm.com/tips/sendmail.asp
^-Using their code, you can see:

<%
On Error resume Next
Dim MyCDO
Set MyCDO = Server.CreateObject("CDONTS.NewMail")
If IsObject (MyCDO) Then
MyCDO.From = "mail@mail.com (Mr Originating)"
MyCDO.To = "mailto@mail.com (Mr recipient)"
MyCDO.Subject = "Subject of the message"
MyCDO.Body = STRING
MyCDO.value("Reply-to")="reply@mail.com"
MyCDO.Send
Set MyCDO = nothing
Response.Write("Message sent")
Else
Response.Write("Message not sent")
End If
%>

kovalik
09-09-2002, 06:08 PM
I'm sorry if I didn't make myself clear. I'm kinda new at this. I don't want to send the actual recipe in the email, I want to send something like "A recipe recommendation" in the subject of the email and the link to the specific recipe (example) http://www.recipesplus.ca/recipe.asp?recipeID=29 in the body of the email.

With java, it seemed easy, but the email would only have the main resipe.asp page link. It couldn't add the .?recipe=29 part.

Does this make any sense to you?

Thanks for your time,

kovalik:confused:

whammy
09-10-2002, 12:07 AM
Simply retrieve the counter number for that particular recipe from the database... (It's obvious you're already doing this to display the recipe)... and then do something like:


<%
Dim MyCDO
Set MyCDO = Server.CreateObject("CDONTS.NewMail")
If IsObject (MyCDO) Then
MyCDO.From = "webmaster@recipeplus.ca"
MyCDO.To = Request.Form("email")
MyCDO.Subject = "Subject of the message"
MyCDO.Body = "Check out this recipe: " & Chr(13) & Chr(13) & "http://www.recipesplus.ca/recipe.asp?recipeID=" & recipeID & Chr(13)
MyCDO.value("Reply-to")="reply@mail.com"
MyCDO.Send
Set MyCDO = nothing
Response.Write("Message sent")
Else
Response.Write("Message not sent")
End If
%>


That's pretty much the same code that Morgoth was using (minus the On Error Resume Next and a couple of changes, because I'm not sure if the parentheses in the email string would choke CDONTS or not), but I included an example of how to add the recipeID to the querystring for you.

In order to display the recipe on the page, you'd simply request the recipeID from the querystring, like:

recipeID = Request.QueryString("recipeID")

:D

P.S. Of course you could replace "webmaster@recipeplus.ca" with a variable, that being the email address of the sender.

whammy
09-10-2002, 12:17 AM
P.S. Wow. That's a pretty nice website. I think I might try a couple of recipes from there myself... but I am going to have to send you some recipes as well!

My family is full of good cooks with amazing recipes that people request over and over for a lifetime. :)

I'm not one of the people who cooks, I'm one of the people who requests! And I'm telling you what... my mouth is watering already thinking about some of the delicacies my Mother, Brother, and Sister-In-Law make, among others. :)

P.S. This tip from Sue is really important:

• Cook hamburger to an internal temperature of 155°F ( 68°C) or until no pink remains in the meat. A meat thermometer is a handy tool to have to determine when food is cooked to a safe and/or desired degree of doneness.

If you do that, you don't ever need to worry about e.coli bacteria, or meat recalls because of it. ;)

kovalik
09-10-2002, 12:31 AM
Thanks for the kind words and help! I'll try it all out.

kovalik:o

Morgoth
09-10-2002, 12:47 AM
I'm sorry that I didn't understand you.

kovalik
09-10-2002, 03:22 AM
I got it working!!!!!!!!!!!!

Thanks again for all your time.

kovalik:thumbsup: