ImportBodyText Method


Sets value of BodyText property by importing contents of specified file. HTML import option is also available.

In HTML Import mode the following considerations are used while scanning tags of specified html file:

Also, if HTML Import mode is active, the method sets BodyFormat=1 (HTML Format).

The method also offers some options to determine the charset of the file being imported.


blnResult = ObjectName.ImportBodyText(FilePath, [HTMLImport], [AppendMode])  
Parameters:  
FilePath As String The path to the file containing body text  
HTMLImport As Boolean (optional) If True, HTML import mode is active. In this mode MailBee scans specified file for embedded objects, images, etc. and adds them as inline attachments to the message. If False, plain text import is assumed. Default value is False  
AppendMode As Boolean (optional) If True, BodyText value is not overwritten by this method, but extended with value generated by ImportBodyText method. Default is False  
Charset As String (optional) The charset of the file being imported. If not specified, MailBee will assume the system default encoding to set the charset. In case of HTML import, however, MailBee by default detects the charset from the META charset tag specified in the HTML source itself.  
CharsetOptions As Long

(optional) A set of flags (some of which can be combined together) which affect how the charset of the HTML file being imported will be determined:
1 - Leave META charset tag in the HTML if it's there (cannot be combined with flag value 4). If this flag is not set, META charset tag is always removed from the imported HTML source.
2 - Set the determined charset for the entire message (Message.Charset property). Lets you automatically set the charset for the message based on the charset in the HTML file being imported. You'll usually combine this with flag 1, i.e. 1 + 2 = 3.
4 - Ignore META charset tag value contained in the HTML file if the charset was explicitly specified in Charset parameter.

The default value is 0 which means the following:

- META charset tag is removed from the HTML source
- If META charset tag was present in the HTML source, it will be used to determine the charset of the HTML
- If META charset tag was NOT present in the HTML, MailBee will use Charset parameter to determine the charset
- If both META charset and Charset parameters are not available, MailBee will assume the default system encoding to determine the charset
- The charset of the e-mail message itself (Message.Charset property) will be left intact. By default, it's "utf-8".

 
Return value As Boolean True if successful. False if error has occurred (file not found, i/o error, etc.)  

Usage example:

Dim Mailer
'Using visual basic to create object
Set Mailer = CreateObject("MailBee.SMTP")
'Using ASP to create object
'Set Mailer = Server.CreateObject("MailBee.SMTP")
'In ASP use Response.Write instead of MsgBox
Mailer.LicenseKey = "put your license key here"
Mailer.ServerName = "mail.server.com"
If Mailer.Connect Then
  Mailer.Message.ToAddr = "bill@yoursite.com"
  Mailer.Message.FromAddr = "joe@mysite.com"
  Mailer.Message.Subject = "Hello"
  Mailer.Message.ImportBodyText "C:\docs\letter.htm", True
  Mailer.Send
  Mailer.Disconnect
End If

See Also:

ImportAltBodyText Method
BodyText Property
BodyFormat Property


Copyright © 2002-2024, AfterLogic Corporation. All rights reserved.