CMailMessage::EnumAttachments Method  
 
INT EnumAttachments(
  LPCTSTR* lpFileNames,  
  INT nMaxFiles  
);

The EnumAttachments method enumerates all of the file attachments in the current message.

Parameters

lpFileNames
A pointer to a an array of null-terminated strings that contain the names of the files attached to the message. If this parameter is NULL, the method will only return the number of files attached to the message.
nMaxFiles
An integer value that specifies the maximum size of the array of string pointers specified by the lpFileNames parameter. If this value is zero, the lpFileNames parameter is ignored and the method will only return the number of files attached to the message.

Return Value

If the method succeeds, the return value is the number of files attached to the message. If the message does not contain any file attachments, this method will return a value of zero. If the method fails, the return value is MIME_ERROR. To get extended error information, call GetLastError.

Example

LPCTSTR lpszFiles[MAXFILES];

INT nFiles = pMessage->EnumAttachments(lpszFiles, MAXFILES);
if (nFiles == MIME_ERROR)
{
    DWORD dwError = pMessage->GetLastError();
    _tprintf(_T("Unable to enumerate attachments, error 0x%08lx\n"), dwError);
    return;
}    

_tprintf(_T("There are %d files attached to the message\n"), nFiles);

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

AttachFile, ExportMessage, ExtractAllFiles, GetAttachedFileName, ImportMessage