IMimeMessage::AttachFile method

Attaches the contents of a file to the message.

Syntax

HRESULT AttachFile(
  [in]           LPCSTR  pszFilePath,
  [in, optional] IStream *pstmFile,
  [out]          LPHBODY phBody
);

Parameters

pszFilePath [in]

Type: LPCSTR

Specifies the path and filename of the file to attach. When pstmFile is NULL, pszFilePath is used to indicate the file to attach. In this case, the file must exist and MimeOLE must have read access to it. Otherwise, pszFilePath is used only to indicate the filename of the attached file, which might not exist.

pstmFile [in, optional]

Type: IStream*

Specifies a pointer to the IStream object for the file to attach. MimeOLE increments the reference count for this object and does not release it until the whole message object is freed or until HandsOffStorage is called.

phBody [out]

Type: LPHBODY

Receives the handle of the new body.

Return value

Type: HRESULT

Returns one of the following values.

Return code Description
S_OK
Indicates success.
E_FAIL
Indicates that an unknown error has occurred.
E_INVALIDARG
Indicates that pszFilePath is NULL.
E_OUTOFMEMORY
Indicates an attempt to allocate memory failed.

Remarks

This method creates the attachment in the multipart/mixed section of the message. If a multipart/mixed section does not exist, one is created.

Data in the object that pszFilePath points to must be stored in either IET_BINARY or IET_DECODED type. For more information, see ENCODINGTYPE.

The method sets the PID_HDR_CNTTYPE property of the new attachment from the extension specified in pszFilePath.

This method sets the PID_ATT_FILENAME property of the new attachment and sets the PID_HDR_CNTDISP property to "attachment".

Requirements

Minimum supported client
Windows XP [desktop apps only]
Minimum supported server
Windows Server 2003 [desktop apps only]
Product
Outlook Express 6.0
Header
Mimeole.h
IDL
Mimeole.idl
DLL
Inetcomm.dll (version 6.0 or later)