IdIMAP41 read e-mail - almost done

Giganews Newsgroups
Subject: IdIMAP41 read e-mail - almost done
Posted by:  Sneek (roel.slang…@rentacar.be)
Date: Wed, 27 Sep 2006

Hallo,

Do I need to include a library???
I got this far, but the compiler give an error on:

< TheImap.GetUID(i,TheUID); >

error-message:
Undeclared Identifier: 'GetUID'

functionality of the code:
- check and count the exchange server 2003 for unred e-mails
- display the oldest date of the unred e-mails found
- if there are more than x unred e-mails open exchange 2003 browser window ,
so the actor can read his e-mails.

code
---------------------------------------------
var
  i,Not_red : Integer;
  TheUID: String;
  TheMsg: TIdMessage;
  TheFlags : TIdMessageFlagsSet;
  TheImap: TIdIMAP4;
begin
  i := 0;
  TheImap := TIdIMAP4.Create(nil);
  datum_nu.Caption := DateToStr(Date);
  TheImap.Host := 'mail.rentacar.be';
  TheImap.Username := 'myaccount';
  The.Imap.Password := 'mypassword';
try
  // connecteer met extended IMAP
    TheImap.Connect();
    try
      // check of connectie ssl gebruikt
      if TheImap.ConnectionState <> csNonAuthenticated then begin
        TheMsg := TidMessage.Create(nil);
        TheImap.SelectMailBox(INBOX');
          for i := 1 to TheImap.MailBox.TotalMsgs - 1 do begin
***** TheImap.GetUID(i,TheUID); *************************************
            TheImap.UIDRetrieveFlags(TheUID,TheFlags);
            TheImap.UIDRetrieveHeader(TheUID,TheMsg);
            RichEdit1.Lines.Add(TheUID);
            RichEdit1.Lines.Add(TheMsg.subject);
            if (TheImap.CheckMsgSeen(i) = TRUE) then begin
              inc(Not_red);
            end;
          end;
          i := TheImap.MailBox.TotalMsgs - (Not_red) - 1;
          if (i < 0) then begin
            i := 0;
          end;
          aantal.Caption :=  IntToStr(i) + ' van ' +
IntToStr(TheImap.MailBox.TotalMsgs);
      end;
    except
      raise exception.Create('Clould not connect to Exchange server')
    end;
    TheImap.Disconnect();
  end;
  try
    if (i >= 3) then
      ShellExecute(Handle, 'Open', 'mail.domain.com',nil, Sw_Show)
  except
    raise exception.Create('Could not open Browser window');
  end;
end;

Replies