ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 CoverYourASP --> Sending email from a form --> Part 5

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
98 active users
2456 visitors today
4454 pages today
how is this done?
Tools I use

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

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

Using JMail
To use JMail, set nEmailServer=nEmailJMAIL in include/config.asp. The SendEmail function will then execute the following code...

// get a mail object
oMail = Server.CreateObject ( "JMail.SMTPMail" );

// setup the mail
oMail.Silent = true;
oMail.ServerAddress = 'mail.' + sHostDomain;

if ( sFromEmail == "" )
   oMail.Sender = oMail.ReplyTo = 'Anonymous';
else
   oMail.Sender = oMail.ReplyTo = sFromEmail;

var sEmailList = sToEmail.split ( /[\s;,]/ );
var nEmail;

for ( nEmail in sEmailList )
   oMail.AddRecipient ( sEmailList [ nEmail ] );

sEmailList = sBccEmail.split ( /[\s;,]/ );

for ( nEmail in sEmailList )
   oMail.AddRecipientBcc ( sEmailList [ nEmail ] );

oMail.Subject = sSubject;
oMail.Body = sBody;

// send it
oMail.Execute ( );

Again, very straightfoward code. The main difference from CDONTS is how multiple recipients are handled. JMail requires that the semicolon-separated list is split into an array, then fed into the AddRecipient method one at a time.

Part 6: Using ASPMail...

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems



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!

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?