|  | 
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
| (Unicode C) Embed Image in HTML EmailDemonstrates how to create and send an HTML email with an embedded image. 
 #include <C_CkMailManW.h> #include <C_CkEmailW.h> void ChilkatSample(void) { HCkMailManW mailman; HCkEmailW email; const wchar_t *fileOnDisk; const wchar_t *filePathInHtml; BOOL success; const wchar_t *htmlBody; // 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 = CkMailManW_Create(); // Set the SMTP server. CkMailManW_putSmtpHost(mailman,L"smtp.comcast.net"); // Create a new email object email = CkEmailW_Create(); // Add an embedded image to the HTML email. fileOnDisk = L"images/dude2.gif"; filePathInHtml = L"dudeAbc.gif"; // Embed the GIF image in the email. success = CkEmailW_AddRelatedFile2(email,fileOnDisk,filePathInHtml); if (success != TRUE) { wprintf(L"%s\n",CkMailManW_lastErrorText(mailman)); CkMailManW_Dispose(mailman); CkEmailW_Dispose(email); return; } // The src attribute for the image tag is set to the filePathInHtml: htmlBody = L"<html><body>Embedded Image:<br><img src=\"dudeAbc.gif\"></body></html>"; // Set the basic email stuff: HTML body, subject, "from", "to" CkEmailW_SetHtmlBody(email,htmlBody); CkEmailW_putSubject(email,L"Unicode C HTML email with an embedded image."); success = CkEmailW_AddTo(email,L"Admin",L"admin@chilkatsoft.com"); CkEmailW_putFrom(email,L"Chilkat Support <support@chilkatsoft.com>"); success = CkMailManW_SendEmail(mailman,email); if (success != TRUE) { wprintf(L"%s\n",CkMailManW_lastErrorText(mailman)); } else { wprintf(L"Mail Sent!\n"); } CkMailManW_Dispose(mailman); CkEmailW_Dispose(email); } | ||||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.