Strange if statement missing. 5 lines code

hazamin's Avatar
Light Poster
Hi. I use Indy component for working with pop3. ( C++ Builder)
Code

Code:
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 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); }
raises error on first line with message "If statement missing )"
Value mess is TIdMessage type.
hazamin's Avatar
Light Poster
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;
}  } }
listendinesh's Avatar, Join Date: Aug 2007
Go4Expert Member
"is" should be replaced by "=="...
Code:
if (mess->MessageParts->Items[inindex] is TIdAttachmentFile)
should be
Code:
if (mess->MessageParts->Items[inindex] == TIdAttachmentFile)
hazamin's Avatar
Light Poster
oh, thank you people. But my compiler (C++ Builder 6.0) has no include file <IdAttachmentFile.hpp>. Compiler rise error

"unable to open include file 'IdAttachment.hpp''.
So, could you send this include file via e-mail? My e-mail is: hazamin@mail.com

Big thanks, people.