1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Strange if statement missing. 5 lines code

Discussion in 'C' started by hazamin, Mar 27, 2009.

  1. hazamin

    hazamin New Member

    Joined:
    Mar 10, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. hazamin

    hazamin New Member

    Joined:
    Mar 10, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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;
    }  } }
    
     
  3. listendinesh

    listendinesh New Member

    Joined:
    Aug 3, 2007
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    "is" should be replaced by "=="...
    Code:
    if (mess->MessageParts->Items[inindex] is TIdAttachmentFile)
    should be
    Code:
    if (mess->MessageParts->Items[inindex] == TIdAttachmentFile)
     
  4. hazamin

    hazamin New Member

    Joined:
    Mar 10, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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.
     

Share This Page