Platform SDK: CDO for Windows 2000 |
The GetFieldParameter method returns the value of the specified parameter for the specified Multipurpose Internet Mail Extensions (MIME) header field.
[Visual Basic] Function GetFieldParameter(FieldName as String, Parameter as String) as String [C++] HRESULT GetFieldParameter(BSTR FieldName, BSTR Parameter, BSTR* pVal); [IDL] HRESULT GetFieldParameter([in] BSTR FieldName, [in] BSTR Parameter, [out,retval] BSTR* pVal);
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.
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