here is full listing of code

Code:
void __fastcall TForm1::sf(TObject *Sender)
{
 int inIndex;
AnsiString s;
TListItem *li;
TIdAttachment *Attachment,*Result;

if  (lv1->Items->Count==0) ShowMessage("Нет сообщений");
lvAttachments->Items->Clear();
s="";
Memo1->Clear();

if(lv1->Items->Count>0)
  {
   pop->Retrieve(lv1->Selected->Index+1, mess);
   Label2->Caption=mess->From->Text;
   Label1->Caption=mess->Recipients->EMailAddresses;
   Label3->Caption=mess->Subject;
   Label4->Caption=FormatDateTime("dd mm yyyy hh:mm:ss", mess->Date);
   Memo1->Lines->Add(mess->Body->Text);
   for(int inindex=0; inindex<mess->MessageParts->Count; inindex++)
    {

     if (mess->MessageParts->Items[inindex] is TIdAttachmentFile)
         { li=lvAttachments->Items->Add();
           li->ImageIndex=0;
           li->Caption=TIdAttachmentFile(mess->MessageParts->Items[inindex])->Filename;
           li->SubItems->Add(TIdAttachmentFile(mess->MessageParts->Items[inindex])->ContentType);
          }

    if(mess->MessageParts->Items[inindex] is TIdText)
      {
       Format(" Mime-тип для части %d : % <%s>",[inindex,mess->MessageParts->Items[inindex]->ContentType]);
       if  (mess->MessageParts->Items[inindex] is   TIdAttachmentFile)
         {
          Attachment=TIdAttachmentFile(mess->MessageParts->Items[inindex]);
          if TextIsSame(stFilename, Attachment->Filename)
            {
             Result=Attachment ;
             }
          }
        }
        Result=Null;
}  } }