Sdílet prostřednictvím


GetFieldParameter Method

Topic Last Modified: 2006-06-13

Returns the value of the specified parameter for the specified Multipurpose Internet Mail Extensions (MIME) header field.

Applies To

IBodyPart Interface

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Syntax

Function GetFieldParameter(    FieldName As String,
        Parameter As String) As String
HRESULT GetFieldParameter
(
        BSTR FieldName,
        BSTR Parameter,
        BSTR* pVal
);

Parameters

  • FieldName
    The fully qualified name of the field, such as urn:schemas:mailheader:content-type. Collaboration Data Objects (CDO) string constants are provided for the various field names, such as cdoContentDisposition.
  • Parameter
    The name of the parameter, such as "filename" or "boundary."
  • pVal
    The charset field returned as a reference to a BSTR.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

The GetFieldParameter method can be used to access parameters for MIME fields that contain nested information. One example is the standard MIME header Content-Disposition (the fully resolved name for CDO is urn:schemas:mailheader:content-disposition). When the content disposition is set to "attachment", the field value normally contains a "filename=[name]" portion to indicate to the receiver suggested names to use when storing the content on the file system. You can use the GetFieldParameter to directly access this value, rather than having to parse the string yourself.

Example

This example demonstrates using GetFieldParameter to extract the charset parameter from a Content-Type: text/plain mail header and the border parameter from a Content-Type: multipart header. The Charset property does the first one for you.


Function GetCharset(ByRef iBp As CDO.IBodyPart) As String
   GetTextBodyCharset = iBp.GetFieldParameter("urn:schemas:mailheader:content-type", "charset")
End Function

Function GetMultipartBoundary(iBp As CDO.IBodyPart) As String
  If InStr(0, iBp.ContentMediaType, "multipart") > 1 Then
    GetMultipartBoundary = iBp.GetFieldParameter("urn:schemas:mailheader:content-type", "boundary")
  Else
    GetMultipartBoundary = ""
  End If
End Function