GetHtmlFromPlain Method


Returns html version of specified plain text string by wrapping plain text with html tags (such as <html><head>, <title>, <body>, <pre>) and replacing some special characters with their html equivalents.

You can use this method for creating html body if only plain-text body is available.

If you want to insert the result of this method into another html, you can specify option "generate only body content" (InnerBodyOnly=True). In this case no <html><head><title><body> tags would be generated.


strHtml = ObjectName.GetHtmlFromPlain(PlainText, [Title], [InnerBodyOnly])  
Parameters:  
PlainText As String Source plain text string  
Title As String (optional) If specified (and InnerBodyOnly=False), <title> tag containing the title is added into <head> section  
InnerBodyOnly As Boolean (optional) If True, only section between <body> and </body> tags is returned (<body> and </body> themselves are not returned). Default is False  
Return value As String Html version of the source  

Usage example:

' Example 1
Dim Msg, strHtml
'Using visual basic to create object
Set Msg = CreateObject("MailBee.Message")
'Using ASP to create object
'Set Msg = Server.CreateObject("MailBee.Message")
'In ASP use Response.Write instead of MsgBox
strHtml = Msg.GetHtmlFromPlain("first line" & vbCrLf & "second line", , True)
MsgBox strHtml

' Example 2
Dim Mailer
'Using visual basic to create object Set Mailer = CreateObject("MailBee.SMTP") 'Using ASP to create object 'Set Mailer = Server.CreateObject("MailBee.SMTP") 'In ASP use Response.Write instead of MsgBox Mailer.LicenseKey = "put your license key here" Mailer.ServerName = "mail.server.com" If Mailer.Connect Then Mailer.Message.ToAddr = "bill@yoursite.com" Mailer.Message.FromAddr = "joe@mysite.com" Mailer.Message.Subject = "Hello" Mailer.Message.ImportAltBodyText "C:\docs\letter.txt" Mailer.Message.BodyText = _ Mailer.Message.GetHtmlFromPlain(Mailer.Message.AltBodyText, _ "Important message to you") Mailer.Message.BodyFormat = 1 ' Mark body as html body Mailer.Send Mailer.Disconnect End If

See Also:

Message Object
AltBodyText Property
ImportAltBodyText Method
GetPlainFromHtml Method


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