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
Embed Image in HTML EmailDemonstrates how to create and send an HTML email with an embedded image. Downloads: MS Windows Visual C/C++ Libraries Linux/CentOS C/C++ Libraries MAC OS X C/C++ Libraries Solaris C/C++ Libraries C++ Builder Libraries #include <C_CkMailMan.h> #include <C_CkEmail.h> void ChilkatSample(void) { HCkMailMan mailman; BOOL success; HCkEmail email; const char * fileOnDisk; const char * filePathInHtml; const char * htmlBody; // The mailman object is used for sending and receiving email. mailman = CkMailMan_Create(); // Any string argument automatically begins the 30-day trial. success = CkMailMan_UnlockComponent(mailman,"30-day trial"); if (success != TRUE) { printf("Component unlock failed\n"); return; } // Set the SMTP server. CkMailMan_putSmtpHost(mailman,"smtp.comcast.net"); // Create a new email object email = CkEmail_Create(); // Add an embedded image to the HTML email. fileOnDisk = "images/dude2.gif"; filePathInHtml = "something/dudeAbc.gif"; // Embed the GIF image in the email. success = CkEmail_AddRelatedFile2(email,fileOnDisk,filePathInHtml); if (success != TRUE) { printf("%s\n",CkEmail_lastErrorText(email)); return; } // The src attribute for the image tag is set to the filePathInHtml: htmlBody = "<html><body>Embedded Image:<br><img src=\"something/dudeAbc.gif\"></body></html>"; // Set the basic email stuff: HTML body, subject, "from", "to" CkEmail_SetHtmlBody(email,htmlBody); CkEmail_putSubject(email,"C HTML email with an embedded image."); CkEmail_AddTo(email,"Admin","admin@chilkatsoft.com"); CkEmail_putFrom(email,"Chilkat Support <support@chilkatsoft.com>"); success = CkMailMan_SendEmail(mailman,email); if (success != TRUE) { printf("%s\n",CkMailMan_lastErrorText(mailman)); } else { printf("Mail Sent!\n"); } CkMailMan_Dispose(mailman); CkEmail_Dispose(email); } |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.