CMailMessage::ExtractAllFiles Method  
 
INT ExtractAllFiles(
  LPCTSTR lpszDirectory  
);

The ExtractAllFiles method extracts all of the file attachments in a message and stores them in the specified directory.

Parameters

lpszDirectory
A pointer to a string which specifies the name of the directory where the file attachments should be stored. If this parameter is NULL or points to an empty string, the attached files will be stored in the current working directory on the local system.

Return Value

If the method succeeds, the return value is the number of file attachments which were extracted from 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.

Remarks

This method will extract all of the files that are attached to the message and store them in the specified directory. The directory must exist and the current user must have the appropriate permissions to create files there. If a file with the same name as the attachment already exists, it will be overwritten with the contents of the attachment. If the file attachment was encoded using base64 or uuencode, this function will automatically decode the contents of the attachment.

To determine the file names for each of the attachments in a message, use the EnumAttachments method. To store a file attachment on the local system using a name that is different than the file name of the attachment, use the ExtractFile 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

MimeAttachFile, EnumAttachments, ExportMessage, ExtractFile, GetAttachedFileName, ImportMessage