Displaying HTML-formatted messages (Part 4)

Advanced topics Summary: Briefly covers usage of optional parameters of previously discussed methods. Lists additional methods useful for embedded objects management.

Tutorial map:
Part 1 - Quickly display e-mail with inline pictures
Part 2 - Using temporary filenames for embedded objects
Part 3 - Removing temporary files after use
Part 4 - Advanced topics

GetBodyWithEmbeddedObjectsEx method supports additional parameters that may be useful for advanced applications. Also, Message object provides several subsidiary methods related to the topic.
Overriding defaults

You can use custom name for message directory created by MailBee in the temporary folder (use MessageDirectoryName parameter of GetBodyWithEmbeddedObjects method). By default, message directory name is generated as MD5-digest of Message-ID. This is fine for most applications but you may override this if you need.

RemoveMessageDirectory method provides an option to delete only the directory content but not delete the directory itself - DeleteContentOnly parameter. By the way,
RemoveMessageDirectory method can be used for deleting or clearing any directories, not necessarily created by MailBee.

Getting info on message directory path

You may check whether message directory exists and it is a folder (not a file) using MessageDirectoryExists method. You may also use this method for testing "is the path is a directory" for any file paths, not necessarily related to MailBee.

To manually get MD5-digest of Message-ID (by default, this digest is used as a message directory name), use GetMD5Digest method. You may also use it for getting MD5 digests of any strings.

"Viewing e-mail securely" sample

The sample below displays HTML message.


Code example:

' HTML message viewer
Dim objPOP3, objMsg

Set objPOP3 = Server.CreateObject("MailBee.POP3")
objPOP3.LicenseKey = "put your license key here"
If objPOP3.Connect("mail.server.com", 110, "test", "pass") Then
  If objPOP3.MessageCount > 0 Then
    Set objMsg = objPOP3.RetrieveSingleMessage(1)
    Response.Write _
      objMsg.GetBodyWithEmbeddedObjectsEx("c:\test_project\files", _
      "http://www.server.com/test/download.asp?", , 3, )
    Session("strMessageDir") = objMsg.GetMessageDirectoryPath
  End If
  objPOP3.Disconnect
Else
  Response.Write objPOP3.ErrDesc
End If

See Also:

GetBodyWithEmbeddedObjectsEx Method
RemoveMessageDirectory Method
GetMessageDirectoryPath Method
MessageDirectoryExists Method
GetMD5Digest Method


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