![]() |
Chilkat • HOME • Android™ • AutoIt • C • C# • C++ • Chilkat2-Python • CkPython • Classic ASP • DataFlex • Delphi DLL • Go • Java • Node.js • Objective-C • PHP Extension • Perl • PowerBuilder • PowerShell • PureBasic • Ruby • SQL Server • Swift • Tcl • Unicode C • Unicode C++ • VB.NET • VBScript • Visual Basic 6.0 • Visual FoxPro • Xojo Plugin
(PureBasic) Embed Image in HTML EmailDemonstrates how to create and send an HTML email with an embedded image.
IncludeFile "CkEmail.pb" IncludeFile "CkMailMan.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. ; The mailman object is used for sending and receiving email. mailman.i = CkMailMan::ckCreate() If mailman.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Set the SMTP server. CkMailMan::setCkSmtpHost(mailman, "smtp.comcast.net") ; Create a new email object email.i = CkEmail::ckCreate() If email.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Add an embedded image to the HTML email. fileOnDisk.s = "images/dude2.gif" filePathInHtml.s = "dudeAbc.gif" ; Embed the GIF image in the email. success.i = CkEmail::ckAddRelatedFile2(email,fileOnDisk,filePathInHtml) If success <> 1 Debug CkMailMan::ckLastErrorText(mailman) CkMailMan::ckDispose(mailman) CkEmail::ckDispose(email) ProcedureReturn EndIf ; The src attribute for the image tag is set to the filePathInHtml: htmlBody.s = "<html><body>Embedded Image:<br><img src=" + Chr(34) + "dudeAbc.gif" + Chr(34) + "></body></html>" ; Set the basic email stuff: HTML body, subject, "from", "to" CkEmail::ckSetHtmlBody(email,htmlBody) CkEmail::setCkSubject(email, "PureBasic HTML email with an embedded image.") success = CkEmail::ckAddTo(email,"Admin","admin@chilkatsoft.com") CkEmail::setCkFrom(email, "Chilkat Support <support@chilkatsoft.com>") success = CkMailMan::ckSendEmail(mailman,email) If success <> 1 Debug CkMailMan::ckLastErrorText(mailman) Else Debug "Mail Sent!" EndIf CkMailMan::ckDispose(mailman) CkEmail::ckDispose(email) ProcedureReturn EndProcedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.