GetBodyWithEmbeddedObjectsEx Method


Visual Basic Tutorial available! (3 pages)

ASP Tutorial available! (4 pages)

Prepares HTML-formatted messages for displaying, also saving embedded objects of the message into default or user-specified temporary location.

GetBodyWithEmbeddedObjectsEx method processes the message body (taken from BodyText property) replacing CIDs (Content-IDs) with corresponding attachments filenames and saving attachments required for displaying the message body (i.e. embedded objects) in specified directory. If the message body has non-HTML format, this stage is skipped.

This method by default also removes META charset information from the HTML message body. See RemoveCharsetFromBody method documentation on why this is useful.

The method returns prepared message body text. Original value of BodyText property is not affected.


strPreparedBody = ObjectName.GetBodyWithEmbeddedObjectsEx([TempDirectoryPath], [VirtualPath], [MessageDirectoryName], [PathBuildingMode], [Options], [Filter])  
Parameters:  
TempDirectoryPath As String (optional) Path to the temporary directory where MailBee will create message directory for storing temporary files. If not specified, the current user's temporary directory will be used  
VirtualPath As String (optional) Virtual path to the physical location of TempDirectoryPath, or downloader URL (see PathBuildingMode parameter). If not specified, defaults to TempDirectoryPath  
MessageDirectoryName As String (optional) The name of the message directory to be created within TempDirectoryPath where temporary files of the current message will be placed. If not specified, the name will be generated by MailBee as MD5 digest of Message-ID  
PathBuildingMode As Long (optional) Specifies the method of creating and translating physical file paths of the attachments into URLs that substitute CIDs in HTML tags. Options supported:
  • 0 - REAL mode (default value). Physical file paths will be used in SRC attributes of the tags. VirtualPath must be equal to TempDirectoryPath (or omitted). In this mode files can get overwritten if there are inline attachments with the same filename.
  • 1 - DIRECT mode. VirtualPath must denote virtual path (e.g. "http://www.server.com/path_to_data") to the physical location of TempDirectoryPath (e.g. "c:\inetpub\wwwroot\data"). Files are stored under real filenames.
  • 2 - INDEX mode. VirtualPath requirements as for DIRECT mode, but files are saved under temporary filenames ("1.jpg", "2.js", etc).
  • 3 - SCRIPT mode. VirtualPath must point to downloader URL (e.g. "http://www.server.com/download.asp?"). Files are saved under temporary filenames (as for INDEX mode). TempDirectoryPath may (and, for better security, should) point to the path unreachable from the web.
  • 4 - DIRECT and INDEX hybrid mode. To the real filename, [digit] index is appended. Ensures that files are not get overwritten even if their filenames are the same but still filenames resemble their original values. This mode produces more accurate results than REAL mode.
 
Options As Long (optional) If 0, META chatset information will be removed from HTML source. If 1, this tag will be left intact. The default is 0 (remove META charset).  
Filter as Object (optional) Reserved for future use. Must be set to Nothing.  
Return value As String If successful, the result is a prepared body text. Otherwise, zero-length string is returned  

Usage example:

Dim Mailer, Msg
'Using visual basic to create object
Set Mailer = CreateObject("MailBee.POP3")
'Using ASP to create object
'Set Mailer = Server.CreateObject("MailBee.POP3")
'In ASP use Response.Write instead of MsgBox
Mailer.LicenseKey = "put your license key here"
Mailer.Connect "mailserver.com", 110, "MyName", "MyPassword"
If Mailer.Connected Then
   If Mailer.MessageCount > 0 Then
      Set Msg = Mailer.RetrieveSingleMessage(1)
      MsgBox Msg.GetBodyWithEmbeddedObjectsEx(, , , 4, , ) ' Hybrid PathBuildingMode
   End If
   Mailer.Disconnect
End If

See Also:

"Displaying HTML-formatted messages in Visual Basic" Tutorial
"Displaying HTML-formatted messages in ASP" Tutorial

GetBodyWithEmbeddedObjects Method
RemoveMessageDirectory Method
GetMessageDirectoryPath Method


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