FindAttachment Method  
 

Search the current message for a file attachment with the specified file name.

Syntax

object.FindAttachment( FileName )

Parameters

FileName
A string the specifies the name of the file attachment to search for. This parameter should only specify a base file name; it should not include a file path and cannot be an empty string.

Return Value

If the method succeeds, the return value is the message part number that contains the file attachment. If the message does not contain an attachment that matches the specified file name, the return value is -1. To get extended error information, check the value of the LastError property.

Remarks

The FindAttachment method will search the current message for a attachment that matches the specified file name. The search is not case-sensitive, however it must match the attachment file name completely. This method will not match partial file names or names that include wildcard characters.

Example

nMessagePart = InternetMail1.FindAttachment(strFileName)

If nMessagePart > -1 Then
    InternetMail1.ExtractFile(strFileName, nMessagePart)
End If

See Also

Attachment Property, AttachFile Method, ExtractAllFiles Method, ExtractFile Method