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
(Tcl) 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.
load ./chilkat.dll # 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. set bdJpg [new_CkBinData] set http [new_CkHttp] set success [CkHttp_QuickGetBd $http "https://www.chilkatsoft.com/images/starfish.jpg" $bdJpg] if {$success == 0} then { puts [CkHttp_lastErrorText $http] delete_CkBinData $bdJpg delete_CkHttp $http exit } set mailman [new_CkMailMan] # Use your SMTP server.. CkMailMan_put_SmtpHost $mailman "smtp.yourserver.com" CkMailMan_put_SmtpPort $mailman 587 CkMailMan_put_StartTLS $mailman 1 # Set the SMTP login/password CkMailMan_put_SmtpUsername $mailman "my_login" CkMailMan_put_SmtpPassword $mailman "my_password" # Create an HTML email. set email [new_CkEmail] CkEmail_put_Subject $email "HTML Email with Image" CkEmail_put_From $email "Dave <somebody@mydomain.com>" CkEmail_AddTo $email "Chilkat" "info@chilkatsoft.com" set html "<html><body><p>This is an HTML email with an embedded image.</p><p><img src=\"starfish.jpg\" /></p></body></html>" CkEmail_SetHtmlBody $email $html # Note: The "starfish.jpg" here must match the name in the "img" tag's "src" attribute in the HTML above. set success [CkEmail_AddRelatedBd2 $email $bdJpg "starfish.jpg"] if {$success == 0} then { puts [CkEmail_lastErrorText $email] delete_CkBinData $bdJpg delete_CkHttp $http delete_CkMailMan $mailman delete_CkEmail $email exit } CkEmail_SaveEml $email "qa_output/out.eml" # success = mailman.SendEmail(email); # if (success == ckfalse) { # println mailman.LastErrorText; # return; # } # # ignore = mailman.CloseSmtpConnection(); puts "Success." delete_CkBinData $bdJpg delete_CkHttp $http delete_CkMailMan $mailman delete_CkEmail $email |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.