Compartir a través de


FileName Property

FileName Property

The FileName property corresponds to the file name parameter attribute used with the Content-Disposition Multipurpose Internet Mail Extensions (MIME) header field.

Syntax

Property FileName as String
read-only
HRESULT get_FileName(BSTR* pVal);

Remarks

The FileName property corresponds to the file name attribute parameter of the Content-Disposition header field of Request for Comments (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 Microsoft 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 example below, the attachments are enumerated, and all associated file names gathered.

Sub ProcessAttachments( iMsg as CDO.Message  )
Dim iBp as CDO.IBodyPart
Dim Filename as String
Dim Atchmts as CDO.IBodyParts
Set Atchmts = iMsg.Attachments
'  Note here 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