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

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
17 active users
175 visitors today
252 pages today
(only part of today)
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 ASPMail
To use ASPMail, set nEmailServer=nEmailASPMAIL in include/config.asp. The SendEmail function will then execute the following code...

// get a mail object
oMail = Server.CreateObject ( "SMTPsvg.Mailer" );

// setup the mail
if ( sFromEmail == "" )
   oMail.ReplyTo = 'Anonymous';
else
   oMail.ReplyTo = sFromEmail;

// =========================
// important - ASPMail only works if the
// FromAddress is the same domain as
// the RemoteHost domain
// =========================
oMail.FromAddress = 'james@' + sHostDomain;
oMail.RemoteHost = 'mail.' + sHostDomain;

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

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

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

for ( nEmail in sEmailList )
   oMail.AddBCC ( "", sEmailList [ nEmail ] );

oMail.Subject = sSubject;
oMail.BodyText = sBody;

// send it
oMail.SendMail ( );

Very similar to the JMail component, ASPMail also needs multiple recipients sent into an AddRecipient method individually.

Take note of the comment above concerning the FromAddress and RemoteHost properties. I wasted some time tracking down that problem! ASPMail is actually the email system used on CoverYourASP.

Part 7: Using ASPEmail...

Featured sponsor
My favorite resources


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...


See my source code
wherever you see this icon...

You can also download the entire site source code for FREE!