Get file attachment's total count of message.
[Syntax] C++: HRESULT GetAttachmentCount( long* pVal ) Visual Basic: GetAttachmentCount() As long C#: long GetAttachmentCount()
Return Value
This method returns file attachment's total count of message.
Usage Example
[Visual Basic]
Sub ParseAttachments( emailFile As String )
Dim oMsg As ANPOPLib.POPMSG
Dim i, nRet, nCount, nSize As Integer
Dim tempFolder, fileName, err As String
Set oMsg = new ANPOPLib.POPMSG
nRet = oMsg.ImportFile( emailFile )
If nRet <> 0 Then
err = "error with ImportFile"
GoTo ErrorHandler
End If
tempFolder = "c:\temp_attachments"
If oMsg.CreateFolder( tempFolder ) <> 0 Then
err = "error with Create temporary folder"
GoTo ErrorHandler
End If
nCount = oMsg.GetAttachmentCount() 'get total count of attachments
For i = 1 To nCount
fileName = oMsg.GetAttachmentName(i) 'get attachment name
nSize = oMsg.GetAttachmentSize(i) 'get attachment size
If oMsg.SaveAttachment( tempFolder, i ) <> 0 Then 'save attachment to temporary directory
err = "error with SaveAttachment"
GoTo ErrorHandler
End If
Next
ErrorHandler:
Set oMsg = Nothing
End Sub
See Also
GetAttachmentChunk Method
GetAttachmentName Method
GetAttachmentSize Method
SaveAttachment Method
SaveAttachmentAs Method
2001-2007 © Copyright AdminSystem Software Limited. All rights reserved.