As given above the this acts as an email page ready
to send to any email server.This acts as a product recommendation tool so that your recepient receives the product
details.He actually gets a link in the message section of his email .if he clicks
on it he is taken to the productdetails of the product.
If u want to test it…try keeping your favourite
messenger on and try sending a mail to yourself and see the results.
And
most important thing is that you have to be connected to the internet and have
to know the smtp server id or the
gateway of the internet source connection.Change in the code and rerun it.
private void
Page_Load(object sender, System.EventArgs e)
{
string name =Convert.ToString(Request.Params["productname"]);
string id
=Convert.ToString(Request.Params["productid"]);
Session["prdid"]=id;
lblProductName.Text="Thanks
for recommending " + name + " to your friend";
lblTitle.Text=" The Recommend to a friend
page allows you to send album/book/Jewellery recommendations to your friends
and relatives (All fields with * are mandatory to add a new friend).Once you
complete either of these, you can click the Recommend button to confirm your
selection";
txtMailServer.Text="172.16.1.1";
// THIS IS VERY IMPORTANT FIELD u HAVE TO CHANGE OVER
HERE..pLEASE ENTER THE SMTPSERVER ID IF U ARE USING OUTLOOK OR YOUR GATEWAY
ADDRESS.
string
url="http://localhost/prjstart/productdetails.aspx?productId="+ id; // THIS GIVES THE URL SO THAT THE RECEIPIENT CAN CLICK 0N
IT
//url +="<a href
string message= "Greetings!! From Emall .Your
friend " + txtYourName.Text +
" has sent you the the following link.Please do visit the site for we have
a vareity of things in store for you";
txtMessage.Text=
message +" "+ url;
}
private void
cmdRecommend_Click(object sender,
System.EventArgs e)
{
string sTo, sFrom, sSubject, sBody ,sMailServer;
int iLoop1;
if(validation())
{
try
{
sTo
= txtTo.Text.Trim();
sFrom
= txtFrom.Text.Trim();
sSubject
= txtSubject.Text.Trim();
sBody
= txtMessage.Text.Trim();
sMailServer
= txtMailServer.Text.Trim();
MailMessage
MyMail = new MailMessage(); // SMTPMAIL IS A CLASS PRESENT IN SYSTEM.WEB.MAIL
NAMESPACE.
// THIS IS A CODE TO SEND AN EMAIL.
MyMail.From
= sFrom;
MyMail.To
= sTo;
MyMail.Subject
= sSubject;
MyMail.Body
= sBody;
SmtpMail.SmtpServer
= sMailServer;
SmtpMail.Send(MyMail);
Response.Redirect("emailsuccessful.aspx");
}
catch(Exception em)
{
Response.Write(em.Message);
}
}
}