Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
Convert Email HTML to Plain-Text AlternativeLoads an HTML email from a web page, converts the HTML to a plain-text alternative body, and sends it.
LOCAL loMailman LOCAL loMht LOCAL lnSuccess LOCAL loEmail LOCAL loH2t LOCAL lcHtml LOCAL lcPlainText * The mailman object is used for receiving (POP3) * and sending (SMTP) email. loMailman = CreateObject('Chilkat.MailMan2') * The MHT component can be used to convert an HTML page * from a URL, file, or in-memory HTML into an email * with embedded images and style sheets. loMht = CreateObject('Chilkat.Mht') * Any string argument automatically begins the 30-day trial. lnSuccess = loMailman.UnlockComponent("30-day trial") IF (lnSuccess <> 1) THEN =MESSAGEBOX("MailMan component unlock failed") QUIT ENDIF lnSuccess = loMht.UnlockComponent("30-day trial") IF (lnSuccess <> 1) THEN =MESSAGEBOX("Mht component unlock failed") QUIT ENDIF loMht.UseCids = 1 loEmail = loMht.GetEmail("http://www.bonairefishing.com/") IF (loEmail = NULL ) THEN =MESSAGEBOX(loMht.LastErrorText) QUIT ENDIF loEmail.Subject = "Test HTML/plain-text email" loEmail.AddTo("Chilkat Support","support@chilkatsoft.com") loEmail.From = "admin@chilkatsoft.com" loH2t = CreateObject('Chilkat.HtmlToText') lnSuccess = loH2t.UnlockComponent("Anything for 30-day trial") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loH2t.LastErrorText) QUIT ENDIF * Get the email's HTML body. lcHtml = loEmail.GetHtmlBody() * Convert it to plain text: lcPlainText = loH2t.ToText(lcHtml) * Add a plain-text alternative to the email: loEmail.AddPlainTextAlternativeBody(lcPlainText) loMailman.SmtpHost = "mail.chilkatsoft.com" loMailman.SmtpUsername = "admin@chilkatsoft.com" loMailman.SmtpPassword = "*myPassword5*" lnSuccess = loMailman.SendEmail(loEmail) IF (lnSuccess <> 1) THEN =MESSAGEBOX(loMailman.LastErrorText) QUIT ENDIF RELEASE loEmail =MESSAGEBOX("HTML/plain-text Email Sent!") |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser