 |
Creating and sending HTML email in Visual Basic - Part
2
|
by: AfterLogic
Importing HTML file into message body
This tutorial briefly
explains how to import HTML file into the message body and
automatically
attach pictures and other objects this HTML
file depends on using AfterLogic's MailBee
SMTP component in Visual Basic.
Tutorial map:
Part 1 - Sending simple HTML e-mail
Part 2 - Importing HTML file into message
body
Part 3 - Assembling body text from different
sources
Part 4 - Building alternative message body
Part 5 - Advanced topics
Message.ImportBodyText method
reads content of the file specified in
FilePath parameter
into the message body. This is the only required
parameter of ImportBodyText method.
Because
message body may have various formats (usually
plain-text and HTML), ImportBodyText also
supports optional parameter HTMLImport that denotes whether to treat the content
as plain-text or as HTML.
If
HTMLImport=False (this is default value),
the file content is just copied into message
body and the body is marked as plain-text.
If
used for importing HTML (HTMLImport=True),
the body is marked as HTML, and ImportBodyText method also parses imported HTML document
looking for any objects related to the document
(such as images, scripts and stylesheets).
Every object found is appended to the message
as inline attachment.
Code 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")
Mailer.LicenseKey
= "put your license
key here"
Mailer.ServerName = "mail.site.com"
Mailer.Message.ToAddr
= "Bill Smith<bill@server1.com>,
Dex<dex1979@server2.com>"
Mailer.Message.FromAddr = "John Doe <jdoe@site.com>"
Mailer.Message.Subject = "This is HTML
message"
'
Import "email.htm" file as HTML
(including embedded pictures, scripts, etc.)
' If related images/scripts/etc are available
on the disk, they will be added as
' inline attachments (i.e. embedded objects)
Mailer.Message.ImportBodyText "C:\docs\email.htm",
True
Mailer.Send
Mailer.Disconnect
About AfterLogic
AfterLogic specializes in email and messaging components.
You can visit AfterLogic at http://www.afterlogic.com/.
Here you can download evaluations for all their email and messaging components
and get
support.
© Copyright 2002-2005 Afterlogic,
an iForum LLC division
|