Compartir a través de


GetFieldParameter Method

GetFieldParameter Method

The GetFieldParameter method returns the value of the specified parameter for the specified Multipurpose Internet Mail Extensions (MIME) header field.

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. Microsoft 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.

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 method to directly access this value rather than parsing the string yourself.

Example

This example demonstrates how to use the GetFieldParameter method 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 Sub


Sub 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 Sub