 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Danijel B. Guest
|
Posted: Wed Mar 16, 2005 4:31 pm Post subject: Fetching IMAP4-Mailheaders (indy_9/Kylix3-Prof.) |
|
|
Im fetching imap4-headers of about 16.000 mails with
"Connection.RetrieveHeader" but my function is to slow!
Code of my function:
--------------------------------------------------- BOF --
function CustomRetrieveAllHeaders( AConnection: TwcIMAP4;
AMsgList: TIdMessageCollection): Boolean;
var
...
const
...
begin
if ( AConnection.ConnectionState = csSelected ) then
begin
if ( AMsgList <> nil ) then
begin
Result := True;
if AConnection.MailBox.TotalMsgs > 0 then
begin
for i := 1 to AConnection.MailBox.TotalMsgs do
begin
LMsgItem := AMsgList.Add;
if not AConnection.RetrieveHeader ( i, LMsgItem.IdMessage ) then
begin
Result := False;
Break;
end
else begin
lblProgressInfo.Caption := ' header '+IntToStr(i) +
' of ' +
IntToStr(AConnection.MailBox.TotalMsgs);
Application.ProcessMessages;
end;
end;
end;
end;
end
else begin
Result := False;
end;
end
else begin
raise EIdConnectionStateError.CreateFmt(RSIMAP4ConnectionStateError,
[GetConnectionStateName(AConnection.ConnectionState)] );
Result := False;
end;
end;
--------------------------------------------------- EOF --
Somebody an idea how to speed up this function?
If yes please let me know hot to do this.
Thank you very much!
Danijel
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Mar 16, 2005 6:20 pm Post subject: Re: Fetching IMAP4-Mailheaders (indy_9/Kylix3-Prof.) |
|
|
"Danijel B." <dado (AT) twc (DOT) de> wrote
| Quote: | Im fetching imap4-headers of about 16.000 mails with
"Connection.RetrieveHeader" but my function is to slow!
|
I see at least two reasons for that:
1) you did not call the TIdMessageCollection's BeginUpdate() and EndUpdate()
methods at all
2) you are calling Application.ProcessMessages() for each iteration of the
loop. That in itself will slow down your code considerably. Don't call it
for every iteration. Call it every 10th, 100th, etc. iteration instead. Or
better, don't call it at all.
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|