GetAttachmentName Method

Get specified file attachment's name.

[Syntax]
C++: HRESULT GetAttachmentName( int nCount, BSTR* pVal )
Visual Basic: GetAttachmentName( nCount As Integer ) As String
C#: string GetAttachmentName( 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 name.

Usage Example

[C#]
public void ParseAttachments( string emailFile )
{
  int i = 0, nRet = 0, nCount = 0, nSize;
  string tempFolder = "c:\\temp_attachments", fileName = "";
  POPMSGClass oMsg = new POPMSGClass();
  
  try
  {
    nRet = oMsg.ImportFile( emailFile );
    if( nRet != 0 )
      throw new Exception( "error with ImportFile" );

    if( oMsg.CreateFolder( tempFolder )!= 0 )
      throw new Exception( "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 new Exception( "error with SaveAttachment" );
    }
  }
  catch( Exception e )
  {
    Console.WriteLine( e.Message );
  } 
  oMsg = null;
}

See Also

GetAttachmentCount Method
GetAttachmentChunk Method
GetAttachmentSize Method
SaveAttachment Method
SaveAttachmentAs Method


2001-2007 © Copyright AdminSystem Software Limited. All rights reserved.