CMailMessage::AttachFile Method  
 
BOOL AttachFile(
  LPCTSTR lpszFileName,  
  DWORD dwOptions  
);

The AttachFile method attaches the specified file to the message.

Parameters

lpszFileName
Pointer to a string which specifies the name of the file to be attached to the message.
dwOptions
A value which specifies one or more options. This parameter is constructed by using a bitwise operator with any of the following values:
Value Description
MIME_ATTACH_DEFAULT The file attachment encoding is based on the file content type. Text files are not encoded, and binary files are encoded using the standard base64 encoding algorithm. This is the default option for file attachments.
MIME_ATTACH_BASE64 The file attachment is always encoded using the standard base64 algorithm, even if the attached file is a plain text file.
MIME_ATTACH_UUCODE The file attachment is always encoded using the uuencode algorithm, even if the attached file is a plain text file.

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 GetLastError.

Remarks

If the specified message is not a multipart message, it is marked as multipart and the attached 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 data that is stored in a memory buffer rather than a file, use the AttachData method.

Requirements

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

See Also

AttachData, ExportMessage, ExtractFile, GetAttachedFileName, GetFileContentType, ImportMessage, SetFileContentType