Hi all,
Iam trying to build a basic tell-a-friend script in ASP.One friend can input his name, email & his friend’s email in the form on the website & click Submit. Upon that, the process.asp file will process the request & it will send a message to the friend of the submitter saying that his friend has referred a website. The email that this friend receives will have the name & email of the sender in the email body along with a custom message. I wanted to create this custom message as a template in HTML which I can change any time & this changed version of the page will be what the receiver will receive after I change it. I tried many tutorials but in vain. Finally I arrived on www.w3schools.com website. Now this one almost provided me with a solution I was looking for but not complete. I can send an HTML page using this command:
myMail.CreateMHTMLBody “http://www.w3schools.com/asp/”
So all I had to do was replace the link with mine like:
myMail.CreateMHTMLBody “http://www.mydomain.com/dir1/template.html”
That’s good. But now I wanted this template to even show the sender’s name
& email which will be kind of dynamic & I don’t know how to return values
from the form.
So I wanted the friend to receive a message like:
Hi,
Your friend (Sender’s name)
With email (Sender’s email)
has sent you an invitation. Visit this website www.mydomain.com
where the sender’s name is the actual sender’s name & his email will be
visible in Sender’s email area. Iam posting the process.asp form below. Any
help to make this form work like I was thinking will be highly appreciated.
Thanks in advance.
‘’’’’’’’’’’’’’’’’‘CODE’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
<%
dim reqfrom
dim reqbody
dim reqbody2
'from email
reqfrom = Trim(Request.Form("sender_email"))
'from name
reqbody = Trim(Request.Form("sender_name"))
'friend email
reqbody2 = Trim(Request.Form("receiver"))
If reqfrom="" OR reqbody2 = "" Then
Response.Redirect("http://www.mydomain.com")
Else
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Hello!"
myMail.From= "myemail@mydomain.com"
myMail.To= reqbody2
myMail.CreateMHTMLBody = ("Hi,<br>Your friend: ") + reqbody + ("<br>With email: ") + reqfrom
+ ("http://www.mydomain.com/dir1/template.html")
myMail.Send
set myMail=nothing
Response.Redirect("http://www.mydomain.com/thanks.html")
End If
%>