Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

November 20, 2007

Email Attachments vs. Embedded Images (Related Items)

The Chilkat Email component makes a distinction between what is considered an attachment, and what is a "related item". Related items are things such as images and style sheets (CSS files) that are present because they contribute to the visual presentation of the email’s HTML body. These items can be accessed and saved using Chilkat just as proper attachments by using the "Related" methods and properties (see the C++ CkEmail header snippet below).

Here are examples that show how to save related items to the filesystem:

ASP: Save HTML Email Embedded Images
SQL Server: Save HTML Email Embedded Images
C#: Save HTML Email Embedded Images
C++: Save HTML Email Embedded Images
Delphi: Save HTML Email Embedded Images
Visual FoxPro: Save HTML Email Embedded Images
Java: Save HTML Email Embedded Images
Perl: Save HTML Email Embedded Images
Python: Save HTML Email Embedded Images
Ruby: Save HTML Email Embedded Images
VB.NET: Save HTML Email Embedded Images
Visual Basic: Save HTML Email Embedded Images
VBScript: Save HTML Email Embedded Images

This snippet of the CkEmail.h header file shows the "Related" methods and properties:

//
// NOTE: Related items are images, style sheets, or other external resources
// that are included within a multipart/related HTML email and are referenced
// from the HTML via CID URLs.
// 
	
// For HTML emails, the number of related items including images, style sheets, etc. included in the email.
long get_NumRelatedItems(void);
	
// Retrieves a related item's data as a String. All end-of-lines will be translated to CRLF sequences.
// Indexing begins at 0.
bool GetRelatedStringCrLf(long index, const char *charset, CkString &str);
	
// Retrieves the contentID of a related item. Indexing begins at 0.
bool GetRelatedContentID(long index, CkString &strContentID);
bool GetRelatedContentType(long index, CkString &strContentType);
	
// Retrieves a related item's filename. Indexing begins at 0.
bool GetRelatedFilename(long index, CkString &strFilename);
	
// Retrieves a related item's data as a String. All CRLF sequences will be translated
// to single newline characters. Indexing begins at 0.
bool GetRelatedString(long index, const char *charset, CkString &strData);
	
// Retrieves a related item's binary data. Indexing begins at 0.
bool GetRelatedData(long index, CkByteData &buffer);
	
// Saves a related item to a file in a directory. The NumRelatedItems property contains the
// number of related items contained in the email. The function returns True if successful.
// Indexing begins at 0.
bool SaveRelatedItem(long index, const char *directory);
	
void DropRelatedItem(long index);
void DropRelatedItems(void);
	
// Adds the contents of a file to the email and returns the Content-ID.
// Emails formatted in HTML can include images with this call and internally reference the
// image through a "cid" hyperlink.
bool AddRelatedFile(const char *fileName, CkString *strContentID);
bool AddRelatedFile(const char *fileName, CkString &strContentID) { return AddRelatedFile(fileName,&strContentID); }
	
bool AddRelatedFile2(const char *fileNameOnDisk, const char *filenameInHtml);
void AddRelatedData2(const unsigned char *data, unsigned long dataLen, const char *fileNameInHtml);
void AddRelatedString2(const char *str, const char *charset, const char *filenameInHtml);
	
// Adds the contents of a memory data buffer to the email and returns the Content-ID.
// This data buffer would typically contain image data in GIF or JPG format. Although the data
// comes from an in-memory data buffer, a fictional filename must be provided to (1) determine the
// format of the data, and (2) determine the filename if the related data item was to be saved
// to disk (by the email recipient) and HTML reconstructed.
bool AddRelatedData(const char *nameInHtml, const unsigned char *data, unsigned long dataLen, CkString *strContentId);
bool AddRelatedData(const char *nameInHtml, const unsigned char *data, unsigned long dataLen, CkString &strContentId)
    {
    return AddRelatedData(nameInHtml,data,dataLen,&strContentId);
    }


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.