CMailMessage::AttachImage Method  
 
BOOL AttachImage(
  LPCTSTR lpszImageFile,  
  LPCTSTR lpszContentId  
);

The AttachImage method attaches the specified file to the message as an inline image.

Parameters

lpszImageFile
Pointer to a string which specifies the name of the image file to be attached to the message. This parameter cannot be NULL and must specify the name of an existing file.
lpszContentId
An optional pointer to a null-terminated string which specifies the content ID associated with the inline image. If this parameter is NULL, a random content ID string will be automatically generated.

Return Value

If the method succeeds, the return value is non-zero. If the method fails, the return value is zero. To get extended error information, call the GetLastError method.

Remarks

The AttachImage method enables an application to attach an inline image to the message. Unlike a normal file attachment, this method is designed to be used with HTML formatted email messages that display images attached to the message. The lpszContentId parameter specifies the content ID string that is used with the HTML image tag to reference that image.

If the specified message is not a multipart message, it is marked as multipart and the attached image file is appended to the message. If the message is already a multipart message, an additional part is created and the attachment is added to the message.

To attach regular files to the message, use the AttachFile method.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csmsgv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also