Displaying HTML-formatted messages (Part 4)
Advanced topics
Summary: Briefly covers usage
of optional paramaters of previously discussed methods. Highlights using MessageCensor
component for better e-mail security. 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.
Making e-mail safe and secure
Censoring of HTML content is possible through using MessageCensor component
(Censor parameter). Because viruses are common example of embedded objects,
censoring controlled by GetBodyWithEmbeddedObjectsEx method not only
cuts unsafe code from HTML content, but also prevents saving these objects to
disk (this is important because many antivirus programs interfere with applications
writing virus code to disk).
Note: MessageCensor is a separate FREE component
not included in MailBee package. You may get it from MailBee
web site.
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 using censoring with default rules (these
rules are enough for most applications).
Code example:
' HTML message viewer Dim objPOP3, objCensor, objMsg Set objCensor = Server.CreateObject("MC.MessageCensor") ' license key is not required because MessageCensor is a free component objCensor.SetDefaults 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, Censor) 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-2011, AfterLogic Corporation. All rights reserved.