Wife/Girlfriend/Sister?
Pepper Spray &
Stun Gun Specials!
KEEP THEM SAFE.
 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
21 active users
51 visitors today
184 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!

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!


I share my content

Supporting ASPRSS

Do you need a quick and easy way to link to my articles? All the information you need is published with ASPRSS...