Send Link within an Email from a Webpage

Visual Studio 2005 Pro
SQL Server 2005
C# Programming
Web Project

Within my project, a user can fill out a request. After they save the request to the database, I want to send an email to their supervisor (pulled from a user database). In this e-mail, I want to send a link that will send them to an approval page along with the request number.

I can't seem to find anything on this -- I've seen some PHP forms that MIGHT have it, but I've never even heard of PHP (well, NOW I have).

Is there any way to compose an e-mail from the Web page that can pull these variables and put them in an e-mail message?

I haven't written any code, or I would attach it. :-)

Thanks for any help on this!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You need to create an e-mail in C# on the form submission and you can compose the body of the e-mail and input the link, here's a general link about creating an e-mail in C#:
alghawksAuthor Commented:
Except for two things:

1. The warnings come up that System.web.mail is obsolete so you need to use

2. This doesn't address putting the link in there with the message body. It just has put the body here. That I saw on the crummy MSDN alleged "help" pages on mail.

As I stated, I need to know how to put the link in the message body, including the ID of the just-added request.
I believe the system.web.mail is obsolete is only a warning, it should still let you compile and it should run fine. Do you know how to read information from the database? If you do you would build the hyperlink string while reading information from the database, something like
  myLInk = "<a href=""" & reader("employee_name") & "> my link click here </a>";
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

alghawksAuthor Commented:
I would frown on a programmer who knowingly put obsolete programming in a brand new system, so I will not be using system.web.mail.

I guess I don't understand your question about reading from the SQL database. Well, I know I don't because the "" makes absolutely no sense to me. However, I'm pretty sure it isn't relevant to my question.

This is what I'm trying to do:

The user will update or insert a new request on a web page. On this request page is an ID number which will be stored on the SQL Database, but it is still on the web page in a TextBox (or label for changes because they cannot change the ID once it is inserted).

After they save their changes or new request, I want the program to send an e-mail notification to their supervisor advising them they need to go and approve or deny the request All I want to include in the link is an ID number taken directly from the web page. I want them to click on the link in their e-mail and have it take them to the approval page with the information for that particular ID pulled up.

I cannot possibly be the only one who has ever wanted to do this. I have gotten e-mails: "click here to confirm" and when I get there, it knows who I am. However, I cannot locate the page from which these come to see the coding.
Yeah. Well is there a reason you can't use System.Net.Mail instead of System.Web.Mail. I thought it was already implemented and you were having problems compiling system.web.mail. The other namespace should suffice. When you are generating the email with this namespace you will be given them oppurtunity to add text as part of the email body. It is during this step that you will be able to add the "click here to confirm" link in which you will add some kind of querystring value to the link so it will read: <a href=""> click here to confirm </a> you will need to give each confirmation its own identitiy so when they click the link you will be able to assess where it came from. I assumed it would be stored in the database. It is commons to record the identity of the email in the database when the email is generated and then when the email link is clicked the identity is looked up and confirmed or outputs a message saying it has already been confirmed.
alghawksAuthor Commented:
Perhaps I'm not communicating well. Maybe I'll just try another forum. Thanks anyway.
No, it is probably me that is not communicating correctly. You will need two pages. One that will send the email out and one that will be a landing page for when the link is clicked. You can name them
sendemail.aspx and confirm.aspx . sendemail.aspx will create an email using In order for the user to confirm the email you will have to have a unique identifier. It can be the request id if there is one in the database you are already using. Also you will have a column in your db that says whether or not it has been confirmed so it can be changed when a user goes to this page. Sending the email will be as follows:
MailMessage message = new MailMessage(
               "Subject line.",
               "<a href="" &  requestID & "> click here to confirm </a>");
SmtpClient client = new SmtpClient(server);

Your landing page will be as follows:
myval = Request.QueryString("requestID"); //The Querystring is part of the link from above and will give you the id you need to update the db

Let me know if I'm not being clear or what it is i'm missing.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alghawksAuthor Commented:
I assume this will work (once I switched the double quotation marks for singles within the body) -- I'm now dealing with (what I assume will be) security errors (exception:Failure sending mail) which I assume will be system specific and I'll have to ask around here.

Thanks for sticking with it!!! And thanks for the code explanation!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.