Get specified file attachment's size in bytes.
[Syntax] C++: HRESULT GetAttachmentSize( int nCount, long* pVal ) Visual Basic: GetAttachmentSize( nCount As Integer ) As long C#: long GetAttachmentSize( int nCount )
Parameters
nCount
Ordinal number of file attachment. The minimum value is 1, and the maximum value is returned by method GetAttachmentCount.
Return Value
This method returns specified file attachment's size in bytes.
Usage Example
[Visual C++]
#include <comdef.h>
#include <string>
#include <iostream>
using namespace std;
#import "c:\program files\adminsystem.net\anpop\anpop.dll" no_namespace
void ParseAttachments( LPCSTR emailFile )
{
::CoInitialize( NULL );
int i = 0, nRet = 0, nCount = 0, nSize = 0;
_bstr_t tempFolder = "c:\\temp_attachments", fileName = "";
IPOPMSGPtr oMsg("ANPOP.POPMSG");
try
{
nRet = oMsg->ImportFile( emailFile );
if( nRet != 0 )
throw string( "error with ImportFile" );
if( oMsg->CreateFolder( tempFolder )!= 0 )
throw string( "error with Create temporary folder" );
nCount = oMsg->GetAttachmentCount(); //get total count of attachments
for( i = 1; i <= nCount; i++ )
{
fileName = oMsg->GetAttachmentName(i); //get attachment name
nSize = oMsg->GetAttachmentSize(i); //get attachment size
//save attachment to temporary directory
if( oMsg->SaveAttachment( tempFolder, i ) != 0 )
throw string( "error with SaveAttachment" );
}
}
catch( string &e )
{
cout << e << endl;
}
oMsg.Release();
::CoUninitialize();
}
See Also
GetAttachmentCount Method
GetAttachmentChunk Method
GetAttachmentName Method
SaveAttachment Method
SaveAttachmentAs Method
2001-2007 © Copyright AdminSystem Software Limited. All rights reserved.