BOOL SetFileContentType( |
|
UINT nContentType, |
|
|
LPCTSTR lpszSubtype, |
|
|
LPCTSTR lpszExtension |
|
); |
The SetFileContentType method associates a per-message
content type with a given file name extension. This association is
specific to the message, and is not shared by an other messages that
may be opened by the process.
Parameters
- nContentType
- An identifier which specifies the primary content type. It may
be one of the following values:
Constant |
Description |
MIME_CONTENT_UNKNOWN |
The default content type for the specified extension should
be used. This value should only be used to delete a previously
defined content type. |
MIME_CONTENT_APPLICATION |
The file content is application specific. Examples of this
type of file would be a Microsoft Word document or an
executable program. This is also the default type for files
which have an unrecognized file name extension and contain
binary data. |
MIME_CONTENT_AUDIO |
The file is an audio file in one of several standard
formats. Examples of this type of file would be a Windows
(.wav) file or MPEG3 (.mp3) file. |
MIME_CONTENT_IMAGE |
The file is an image file in one of several standard
formats. Examples of this type of file would be a GIF or JPEG
image file. |
MIME_CONTENT_TEXT |
The file is a text file. This is also the default type for
files which have an unrecognized file name extension and
contain only printable text data. |
MIME_CONTENT_VIDEO |
The file is a video file in one of several standard
formats. Examples of this type of file would be a Windows
(.avi) or Quicktime (.mov) video file. |
- lpszSubtype
- A pointer to a string which specifies the MIME
subtype. This parameter may be NULL if the content type association
is being deleted.
- lpszExtension
- A pointer to a string which specifies the file
name extension that will be associated with the MIME content
type.
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
The SetFileContentType method allows an application to
specify a content type for a given file extension, and is typically
used to define custom content types for file attachments. The content
type will override any default content types associated with the
extension, as well as allow new content types to be defined for
application-specific files.
Example
In the following example, the file extension ".dat" is
associated with a custom content type, a file is attached to the
message and then the custom content type is deleted. Note that
because the primary content type designates the file as an
application specific (non-text) file, it will be automatically
encoded when attached to a message:
bResult = pMessage->SetFileContentType(
MIME_CONTENT_APPLICATION,
_T("octet-stream"), _T("dat"));
if (bResult)
{
bResult = pMessage->AttachFile(lpszFileName, MIME_ATTACH_DEFAULT);
pMessage->SetFileContentType(MIME_CONTENT_UNKNOWN, NULL, _T("dat"));
}
Requirements
Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csmsgv10.lib
Unicode: Implemented as Unicode and ANSI versions.
See Also
AttachData,
AttachFile,
GetFileContentType
|