J-ASP SMTP Mailer

J-ASP SMTP Mail allows you to send mail using the standard SMTP protocol
from any programs that can use Java. Features include:

  1. SMTP (sending) Messages
  2. Multiple File Attachments
  3. US Ascii and ISO-8859-1 character sets
  4. Special Header Support 
  5. Multiple concurrent users

Requirements:

J-ASP Mail is based on Sun's Java Mail API, please set Sun's mail.jar and activation.jar to the classpath.

Simple Mail Example

Using the J-ASP Mail is simple

  1. Creating the object
  2. Setting a few properties
  3. Calling the SendMail method

The following codes demonstrate how to use J-ASP Mail in VBScript. 


Set Mailer = Server.CreateObject("JASP.SmtpMail")
Mailer.FromName   = "Sophia."
Mailer.FromAddress= "sophia@netcoole.com"
Mailer.UserName = "smtp user "
Mailer.Password = "smtp password"
Mailer.RemoteHost = "www.netcoole.com"
Mailer.AddRecipient "davis", "davis@netcoole.net"
Mailer.Subject    = "J-ASP Mail 2.0"
Mailer.BodyText   = "Dear Davis" & VbCrLf & "How are you"
If Mailer.SendMail Then
     Response.Write "Mail sent..."
Else
     Response.Write "Mail send failure. Error was " & Mailer.Response
End If

J-ASP Mail Properties

Property Description Supported
BodyText The message body text.  Yes
CharSet The character set. By default the char set is US Ascii

Valid values:

  • 1 = US Ascii
  • 2 = ISO-8859-1
Yes
ConfirmRead The ConfirmReading flag. If this is set to true AND the recipients email program supports

this feature (and it is enabled) the recipients email program will send a notice back to the FromAddress confirming that this email has been read.

Yes
ContentType The ContentType property allows you to set the ContentType header of the message's BodyText.  Yes
CustomCharSet If you wish to use a character set besides the included types you can set CustomCharSet to a character set string. Yes
DateTime Set 'Date' header Yes
FromName The message originator’s name. Yes
FromAddress The message originator’s email address. Yes
IgnoreMalformedAddress Defaults to false. When false JASPMail will check for '@' in the email address for calls to AddRecipient, AddCC and AddBCC. An error would be returned in the Response property.  Yes
IgnoreRecipientErrors Defaults to true. If true JASPMail will ignore error messages returned by the SMTP server for invalid addresses. This is useful when a mailing is addressed to a number of recipients. Yes
Organization Sets the Organization header in the message. Yes
Priority Sets the message priority. Priorities are 1-5 and are reflected in the X-Priority

Valid values:

  • 1 High
  • 3 Normal
  • 5 Low
Yes
RemoteHost The remote SMTP host that the message will be sent through.  Yes
ReplyTo The ReplyTo property allows you to specify a different email address that replies should be sent to. By default mail programs should use the Reply-To: header for responses if this header is specified. Yes
Response The Response property returns any error messages that may occur. Yes
ReturnReceipt The ReturnReceipt flag. If this is set to true AND the recipients SMTP server supports this feature (and it is enabled) the recipients SMTP server will send a notice back to the FromAddress confirming that this email has been delivered. Yes
SMTPLog If you need to debug the session give a log file name here.  Yes
Subject The message subject. Yes
SuppressMsgBody The SuppressMsgBody property is true by default and is used in conjuction with the SMTPLog property. When SMTPLog is set to a file and SuppressMsgBody is true the log file receives a copy of the message text. If SuppressMsgBody is false the message text is not sent to the log. Yes
Urgent The urgent flag sets the X-Urgent header in the outgoing message. Not all mail readers support this flag. Yes
UseMSMailHeaders MS-Mail priority headers, by default, are sent in addition to the standard SMTP priority headers. You can turn MS-Mail headers off with this property Yes
Version Gets the internal JASPMailer version number. Yes
WordWrap The WordWrap property is off by default. Setting WordWrap to true causes the message body to wordwrap at the position specified by the WordWrapLen property. Yes
WordWrapLen The WordWrapLen property is set to 70 by default. You can modify the position that wordwrap occurs by changing this value. Yes

J-ASP Mail Methods

Method Return Value Description Supported
SendMail True or False The SendMail method attempts to send the email. Yes
AddRecipient True/False based upon success or failure. Adds a new recipient, as shown in the message's To: list. Yes
ClearRecipients None Clears any recipients assigned to the To list. Yes
AddCC True/False based upon success or failure. Adds a new recipient, as shown in the message's CC list. Yes
ClearCCs None Clears any recipients assigned to the CC list. Yes
AddBCC True/False based upon success or failure. Adds a new Blind Carbon Copy recipient. BCC recipients are not shown in any message recipient list. Yes
ClearBCCs None Clears any recipients assigned to the BCC list. Yes
ClearAllRecipients None Clears all recipients assigned to the To, CC and BCC lists. Yes
AddAttachment N/A Adds attachments to current mailing. You must use an explicit path to attach files. Yes
ClearAttachments None Clears any attachments that were previously set. Yes
ClearBodyText None Clears any text assigned to the message’s body which may have been set previously by using the BodyText property. Yes
ClearExtraHeaders None Clears any X-Headers that were set by use of AddExtraHeader. Yes
AddExtraHeader True or false. Returns true if X-Header was added. Adds extra X-Headers to the mail envelope. Yes