Knowledge Essentials - 3Essentials Hosting

Sending mail from a web page using ASP and JMail

Article ID: 27

 Back to Search

JMAIL is the send mail COM component which 3Essentials provides as it's standard send mail COM component for customers on all servers. 

Two downloads are provided to assist 3Essentials customers in using Jmail mail component for sending email from an ASP page.

  • One is a sample form which posts to itself, and takes the form fields and sends them to a defined recipient in the script.
  • The other is the object model documentation from Dimac (the developers of Jmail) which gives a list of all the supported methods and properties... look here for details on expanded functionality of the JMail component (adding attachments, etc..)

For those customers hosted on servers where MAIL ENABLE is the mail server (web4, 6, 8, 10), the MEMail COM object is also available.  The object model for the MEMail COM object is provided here for convenience, although 3Essentials recommends you use the JMAIL component. 


3Essentials strongly recommends customers using the MEMail COM object to send mail switch to JMAIL as 3Essentials will be dropping support for MEMail in the future due to issues surrounding it's support for smtp-authentication.

MEMail COM object reference:

Properties

Property

Explanation

AttachmentFilename

The name of the file that you wish to add as an attachment.

AttachmentName

The name you wish to call the attachment.

ContentType

The ContentType of the email you are trying to send. For instance, if you wish to send a HTML email, use this property to set the content type to HTML.

ErrorString

This contains the full English language description of the last error. If you encounter an error, you can check this string for a more detailed error.

MailBCC

This is list of email addresses to BCC the email to. When using multiple email addresses, separate them with a semi-colon ";".

MailBCCDisplayName

This is list of email addresses that are the display name corresponding to the email address you have set in MailBCC. This list is optional. When using multiple email addresses, separate them with a semi-colon ";".

MailCC

This is list of email addresses to CC the email to. When using multiple email addresses, separate them with a semi-colon ";".

MailCCDisplayName

This is list of email addresses that are the display name corresponding to the email address you have set in MailCC. This list is optional. When using multiple email addresses, separate them with a semi-colon ";".

MailFrom

This is the email address of the person you want as the sender.

MailFromDisplayName

The display name of the from MailFrom email address.

MailTo

The email address to send the email to. If you wish to send to multiple email addresses, separate the emails with a semi-colon ";".

MailToDisplayName

This is the display name that will be shown as the To address. It is usually the full name of the person you are sending to (i.e. "John Smith")

Messagebody

The message contents.

MessageBodyText

An optional property used to force the content for the textual content of the message. If the property is not set, MailEnable will generate a textual version of the message from the HTML content supplied (assuming the ContentType is set as text/html.

Server

The email server to connect to. If none is supplied it will try to connect to the local machine.

ServerPort

The port to connect to. The default is 25.

Subject

The subject of the email message.

 

Methods

Method

Explanation

AddHeader

Adds a custom header to the email. Be careful when using this function, as incorrectly formed headers could prevent the mail from being sent. The Reply-To header is an example of a header that can be set via this method.

ClearHeaders

Clears any custom headers that have been added with AddHeader. This would be used if you were sending more than one message (you put this call between your sends).

SendMessage

Send the email that has been configured with the options. The function will return zero for failure and number greater than zero for success.

SetDefault

This will clear all previous settings to default. If sending multiple emails, use this between the calls.

AddAttachment (Filename, AttachmentName)

This will add an attachment to the message being composed. The first parameter is the Path to the file that you want to attach to the message (eg: C:\My Documents\test.txt). The second parameter is the name that the attachment should have when read via a mail client (eg: test.txt)

ClearAttachments

This will remove all attachments from the message being composed.

 

By setting the ContentType value to text/html, the component will generate a HTML and Plan Text representation of your message encapsulated in MIME format.  You need only to set the ContentType property to text/html and, when the SendMessage method is called, the component generates the MIME encapsulated message with a multipart alternative content boundary. This boundary then contains respective text/plain and text/html boundaries.  The mail client then determines which of the alternative content types it wants to read - based on the capabilities of the mail client or the users settings.

If you set the MessageBody and MessageBodyPlain properties of the component, it will not generate a textual representation of the message and will use the property value specified for MessageBodyPlain.


 
Downloads Associated With This Article
jmailformmail.zip : JMail_FormMailExample