BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fetching IMAP4-Mailheaders (indy_9/Kylix3-Prof.)

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Danijel B.
Guest





PostPosted: Wed Mar 16, 2005 4:31 pm    Post subject: Fetching IMAP4-Mailheaders (indy_9/Kylix3-Prof.) Reply with quote



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





PostPosted: Wed Mar 16, 2005 6:20 pm    Post subject: Re: Fetching IMAP4-Mailheaders (indy_9/Kylix3-Prof.) Reply with quote




"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.