FileName Property (IBodyPart)
Topic Last Modified: 2006-06-13
The FileName property corresponds to the filename parameter attribute used with the Content-Disposition Multipurpose Internet Mail Extensions (MIME) header field. This property is read-only.
Applies To
Type Library
Microsoft CDO for Exchange 2000 Library
DLL Implemented In
CDOEX.DLL
Syntax
Property FileName As String
HRESULT get_FileName(BSTR* pVal);
Parameters
- pVal
Returns the value of the FileName property as a reference to a BSTR.
Remarks
The FileName property corresponds to the filename attribute parameter of the Content-Disposition header field of RFC 2183.
Some applications may interpret the Content-Disposition header field specified as a file to mean that a body part is an attachment. However, there is no specifically-defined presentation behavior determined by the FileName property.
The default value of FileName is an empty string. If Collaboration Data Objects (CDO) does not recognize the disposition of a body part on an incoming message, it is treated as an attachment.
Example
All message attachments are contained in objects that implement the IBodyPart interface. In the following example, the attachments are enumerated, and all associated file names gathered. These names could be used to render attachment bitmaps in a Upgrade Advantage, save it into a file with this name, or make a guess as to its type if, for example, the attachment had Content-Type equal to "application/octet-stream."
Sub ProcessAttachments(iMsg As CDO.Message)
Dim iBp As CDO.BodyPart
Dim Filename As String
Dim Atchmts As CDO.IBodyParts
Set Atchmts = iMsg.Attachments
' Note that all attachments are contained in body
' parts -- the collection object
' exposes the IBodyParts interface.
If Atchmts.Count > 0 Then
For Each iBp In iMsg.Attachments
Filename = iBp.Filename
If Not Filename = "" Then
' Use the file name
End If
Next iBp
End If
End Sub