You are viewing a plain-jane printable version of http://CoverYourASP.com/HowToRecommend.asp.
See how this was done

 

It's obviously important to give your readers a way to tell their friends and colleagues about your site - it's free advertising after all. That's why I put the Tell your friends link at the top of every page.

Luckily, it's very easy to do - it's just another form that sends email. In fact, most of what you need to know is already documented in my article about my feedback form.

Read these first...

1. If you're not familiar with how to write <form>'s with ASP, read my <form> article.
2. Next, read my article about getting feedback email.

What's different...

Well, uh, not much. Both the feedback form and the tell-a-friend form use the same SendEmail email function - it's just that in this case the form asks for both sender and recipient email addresses.

if ( sFromName == '' )
   sFromName = '[Anonymous]';

var sSubject = sFromName + ' wanted you to check this site out';

var sBody = 'Your friend or colleague, ' + sFromName + ', thought that you would like http://' + sHostDomain + '/__I_hope_you/'ll visit!\n\nBest Regards\nJames Shaw\njames@' + sHostDomain;

SendEmail ( sFromEmail, sToEmail, 'Recommended@' + sHostDomain, sSubject, sBody );

I use the word [Anonymous] if the user doesn't supply his name, then make up a subject and body for the email.

sHostDomain is a variable you set in the configuration file (include/config.asp) when you download all my source code to run on your PC. In my case it is set to "CoverYourASP.com". By changing that variable every email and reference to the domain name changes.

What's that "\n" part? That's how you specify a linefeed in JavaScript (or C or C++).

See the actual source code for the page by clicking the icon below.