Previous Topic

Next Topic

Mailer Object

The Mailer Object in MaxBasic is used to create mail messages. If HTML is available (if HTMLAvailable function returns true), the output will be an HTML mail message, otherwise the output will be a text mail message. If the user has selected to Use SMTP Mailing in the User Settings, an SMTP Mail Object will be created.

Note: After Send or ShowForm has been applied to a mailer object, it cannot be modified. You must create a new mailer object using CreateObject to send another mail after Send or ShowForm.

Mailer Object Example

See the example below for creating a Mailer in MaxBasic using the Mailer object:

  Dim Mailer as Object
  Mailer = CreateObject("Accredo.Mailer") ' for SMTP, use Accredo.SMTPMailer
  Mailer.To = "[email protected]"
  Mailer.Subject = "Message from build " & AppVersion(True)
  Mailer.Contents.SetLine(2, "Thank you for your business...")
  Mailer.Contents.SetLine(4, "Attached is your invoice.")
  Mailer.ShowForm ' bring up mail editor

See also the MAILER Snippet, for another MaxBasic Mailer example.

HTML Output Signatures

Using the Mailer object, you can set the Contents property to set the contents of the mailer, such as in the example above. If HTML is available, when the Contents are set, the AddSignature method of the Contents will be automatically called, so the HTML signature will be added.

The Contents.AddSignature and the mailer AddHTMLSignature methods do not add the signature until just before the Send or ShowForm methods are called. So if you read the Contents.Text or HTMLContents before Send or ShowForm, the signature will not be included.

If a mailer is empty, the signature will be loaded when ShowForm is called.

Text Output Signatures

To add a signature to a Text output mailer, use the Contents.AddSignature method.

The Contents.AddSignature method does not add the signature until just before the Send or ShowForm methods are called. So if you read the Contents.Text before Send or ShowForm, the signature will not be included.

Mailer Object Methods

The following methods can be used for mailer objects:

AddEmbeddedAttachment(FileName: String) - Specify a file name to be attached as an embedded file in the mail message.

Resend - Resend the mail message.

Send - Send the mail message.

ShowForm - Display the mail message.

ShowReadOnly(Filename: String) - Displays the mail message saved as Filename as read-only. Filename must be saved as a .eml file.

See Also

MaxBasic Objects

Book Contents

Book Index