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.

Optionally, this method supports censoring the message body text using free MessageCensor component. Censoring is performed BEFORE processing CIDs, so it is possible that some embedded objects (such as scripts, applets, ActiveX'es) would be dropped by the censor and not saved to disk. This avoids overhead of saving unnecessary files.

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


strPreparedBody = ObjectName.GetBodyWithEmbeddedObjectsEx([TempDirectoryPath], [VirtualPath], [MessageDirectoryName], [PathBuildingMode], [Options], [Censor])  
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)
  • 1 - DIRECT mode. VirtualPath must designate 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
 
Options As Long (optional) Reserved for future use. Must be set to zero.  
Filter as MC.MessageCensor (optional) object of MessageCensor class that defines censorship rules. If missing, no censoring is performed  
Return value As String If successful, the result is a prepared body text. Otherwise, zero-length string is returned  

Usage example:

Dim Mailer, Censor, 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)
      Set Censor = CreateObject("MC.MessageCensor")
      'In ASP use Server.CreateObject("MC.MessageCensor")
      Censor.SetDefaults
      MsgBox Msg.GetBodyWithEmbeddedObjectsEx(, , , , , Censor)
   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-2010, AfterLogic Corporation. All rights reserved.