Wife/Girlfriend/Sister?
Pepper Spray &
Stun Gun Specials!
KEEP THEM SAFE.
 CoverYourASP --> Sending email from a form --> Part 3

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
12 active users
31 visitors today
123 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2012 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

Making up the email

Having validated the email address, we need to make up the email and send it.

// make up the message body
var sBody = 'Message: "' + sMessage + '"\n\n';

if ( sFromName != '' )
   sBody += 'From: "' + sFromName + '".\n';

if ( sFromEmail != '' )
   sBody += 'Email: "' + sFromEmail + '".\n';

The body of the email is very simple in this case - this form is sending the information to me, so I just declare an sBody variable and add each data on a new line ( \n is a linefeed character in JavaScript, C, C++, etc ).

sBody += 'Browser: "' + Request.ServerVariables ( "HTTP_USER_AGENT" ) + '".\n';
sBody += 'IP address: "' + Request.ServerVariables ( "REMOTE_ADDR" ) + '".\n';

var dateToday = new Date();

sBody += 'Time: "' + dateToday.getHours() + ':' + dateToday.getMinutes() + '".\n';

Then, I add some more information to the email such as the user agent (browser) that was used, and the IP address of the sender. All this data and much more is available from the Request.ServerVariables collection.

Lastly, I add the time that the email was sent - note that this is server time, not the local client time...

// send Email with our generic function
SendEmail ( sFromEmail, 'Feedback@' + sHostDomain, '', sSubject, sBody );

...and send the email, again using a function defined in the utils/email.asp SSI.

Part 4: Using the SendEmail( ) function...

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems


CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?


New Proposal Kit Professional 5.1
Brand yourself as a top professional: create quotes and amazing proposals and get many legal documents free!

The latter saved me 3 times the purchase price on the first day I owned it!