Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Send HTML Email with Image Downloaded from URLDemonstrates how to compose an HTML email with an embedded image where the image data is downloaded from a URL.
integer li_rc oleobject loo_BdJpg oleobject loo_Http integer li_Success oleobject loo_Mailman oleobject loo_Email string ls_Html // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // First download the image we'll be adding to the HTML "img" tag. loo_BdJpg = create oleobject // Use "Chilkat_9_5_0.BinData" for versions of Chilkat < 10.0.0 li_rc = loo_BdJpg.ConnectToNewObject("Chilkat.BinData") if li_rc < 0 then destroy loo_BdJpg MessageBox("Error","Connecting to COM object failed") return end if loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") li_Success = loo_Http.QuickGetBd("https://www.chilkatsoft.com/images/starfish.jpg",loo_BdJpg) if li_Success = 0 then Write-Debug loo_Http.LastErrorText destroy loo_BdJpg destroy loo_Http return end if loo_Mailman = create oleobject // Use "Chilkat_9_5_0.MailMan" for versions of Chilkat < 10.0.0 li_rc = loo_Mailman.ConnectToNewObject("Chilkat.MailMan") // Use your SMTP server.. loo_Mailman.SmtpHost = "smtp.yourserver.com" loo_Mailman.SmtpPort = 587 loo_Mailman.StartTLS = 1 // Set the SMTP login/password loo_Mailman.SmtpUsername = "my_login" loo_Mailman.SmtpPassword = "my_password" // Create an HTML email. loo_Email = create oleobject // Use "Chilkat_9_5_0.Email" for versions of Chilkat < 10.0.0 li_rc = loo_Email.ConnectToNewObject("Chilkat.Email") loo_Email.Subject = "HTML Email with Image" loo_Email.From = "Dave <somebody@mydomain.com>" loo_Email.AddTo("Chilkat","info@chilkatsoft.com") ls_Html = "<html><body><p>This is an HTML email with an embedded image.</p><p><img src=~"starfish.jpg~" /></p></body></html>" loo_Email.SetHtmlBody(ls_Html) // Note: The "starfish.jpg" here must match the name in the "img" tag's "src" attribute in the HTML above. li_Success = loo_Email.AddRelatedBd2(loo_BdJpg,"starfish.jpg") if li_Success = 0 then Write-Debug loo_Email.LastErrorText destroy loo_BdJpg destroy loo_Http destroy loo_Mailman destroy loo_Email return end if loo_Email.SaveEml("qa_output/out.eml") // success = mailman.SendEmail(email); // if (success == ckfalse) { // println mailman.LastErrorText; // return; // } // // ignore = mailman.CloseSmtpConnection(); Write-Debug "Success." destroy loo_BdJpg destroy loo_Http destroy loo_Mailman destroy loo_Email |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.