Help: Slow 
Author Message
 Help: Slow

The following code loops through each mail item in a specified folder
and moves the item to another folder.  For 1100 items, it takes more
than 5 min.  It doesn't move that slow when I select all and move in
the user interface.  Any ideas?

/* Move all mailitems from primary folder to temp folder */
DO i = chFolderObject:Items:Count() TO 1 BY -1:

  ASSIGN chMailItem = chFolderObject:Items(i).

  IF chMailItem:Class() NE 43 THEN NEXT.  /* 43 = MailItem */

  ASSIGN yn = chMailItem:Move(chTempFolderObject).

END.

Sent via Deja.com
http://www.*-*-*.com/



Mon, 07 Jul 2003 05:24:39 GMT  
 Help: Slow
Outlook uses Extended MAPI to implement a move operation, namely
IMAPIFolder::CopyMessages() which takes a list of entryids, hence it does not
need to open each message. Store provider completes the whole operation on the
server without sending lots of data back and forth as apparently happens when
you run your code.

Dmitry Streblechenko
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

Quote:

> The following code loops through each mail item in a specified folder
> and moves the item to another folder.  For 1100 items, it takes more
> than 5 min.  It doesn't move that slow when I select all and move in
> the user interface.  Any ideas?

> /* Move all mailitems from primary folder to temp folder */
> DO i = chFolderObject:Items:Count() TO 1 BY -1:

>   ASSIGN chMailItem = chFolderObject:Items(i).

>   IF chMailItem:Class() NE 43 THEN NEXT.  /* 43 = MailItem */

>   ASSIGN yn = chMailItem:Move(chTempFolderObject).

> END.

> Sent via Deja.com
> http://www.deja.com/



Mon, 07 Jul 2003 05:43:00 GMT  
 Help: Slow


Quote:
> Outlook uses Extended MAPI to implement a move operation, namely
> IMAPIFolder::CopyMessages() which takes a list of entryids, hence it
does not
> need to open each message. Store provider completes the whole
operation on the
> server without sending lots of data back and forth as apparently
happens when
> you run your code.

But this code problem is happening on a local PC.  If I have thousands
of mail items to process, this could take too long to be feasible.

Any other ideas?

Quote:

> Dmitry Streblechenko
> http://www.dimastr.com/
> OutlookSpy  - Outlook, CDO
> and MAPI Developer Tool




Quote:
> > The following code loops through each mail item in a specified
folder
> > and moves the item to another folder.  For 1100 items, it takes more
> > than 5 min.  It doesn't move that slow when I select all and move in
> > the user interface.  Any ideas?

> > /* Move all mailitems from primary folder to temp folder */
> > DO i = chFolderObject:Items:Count() TO 1 BY -1:

> >   ASSIGN chMailItem = chFolderObject:Items(i).

> >   IF chMailItem:Class() NE 43 THEN NEXT.  /* 43 = MailItem */

> >   ASSIGN yn = chMailItem:Move(chTempFolderObject).

> > END.

> > Sent via Deja.com
> > http://www.deja.com/

Sent via Deja.com
http://www.deja.com/


Mon, 07 Jul 2003 21:41:05 GMT  
 Help: Slow
Use CDO instead of the Outlook object model. It's much, much faster.

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


Quote:


> > Outlook uses Extended MAPI to implement a move operation, namely
> > IMAPIFolder::CopyMessages() which takes a list of entryids, hence
it
> does not
> > need to open each message. Store provider completes the whole
> operation on the
> > server without sending lots of data back and forth as apparently
> happens when
> > you run your code.

> But this code problem is happening on a local PC.  If I have
thousands
> of mail items to process, this could take too long to be feasible.

> Any other ideas?

> > Dmitry Streblechenko
> > http://www.dimastr.com/
> > OutlookSpy  - Outlook, CDO
> > and MAPI Developer Tool



> > > The following code loops through each mail item in a specified
> folder
> > > and moves the item to another folder.  For 1100 items, it takes
more
> > > than 5 min.  It doesn't move that slow when I select all and
move in
> > > the user interface.  Any ideas?

> > > /* Move all mailitems from primary folder to temp folder */
> > > DO i = chFolderObject:Items:Count() TO 1 BY -1:

> > >   ASSIGN chMailItem = chFolderObject:Items(i).

> > >   IF chMailItem:Class() NE 43 THEN NEXT.  /* 43 = MailItem */

> > >   ASSIGN yn = chMailItem:Move(chTempFolderObject).

> > > END.

> > > Sent via Deja.com
> > > http://www.deja.com/

> Sent via Deja.com
> http://www.deja.com/



Mon, 07 Jul 2003 22:09:21 GMT  
 Help: Slow
Doesn't matter: in your case each item must be open (memory allocated,
properties populated, etc), while in Extended MAPI case you can essentially tell
the provider "move items 1, 6, 15 and 26".
I wasn't trying to give you a solution, but simply explain why your code is slow
and Outlook is much faster. You simply hit an Outlook object model limitation -
that's a price to pay for having 5 lines of VB code instead of a hundred lines
of C++ code messing with Extended MAPI

Dmitry Streblechenko
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

Quote:



> > Outlook uses Extended MAPI to implement a move operation, namely
> > IMAPIFolder::CopyMessages() which takes a list of entryids, hence it
> does not
> > need to open each message. Store provider completes the whole
> operation on the
> > server without sending lots of data back and forth as apparently
> happens when
> > you run your code.

> But this code problem is happening on a local PC.  If I have thousands
> of mail items to process, this could take too long to be feasible.

> Any other ideas?



Mon, 07 Jul 2003 22:15:20 GMT  
 Help: Slow


Quote:
> Doesn't matter: in your case each item must be open (memory allocated,
> properties populated, etc), while in Extended MAPI case you can
essentially tell
> the provider "move items 1, 6, 15 and 26".
> I wasn't trying to give you a solution, but simply explain why your

I know, and I appreciate your time and effort.

code is slow

Quote:
> and Outlook is much faster. You simply hit an Outlook object model
limitation -
> that's a price to pay for having 5 lines of VB code instead of a
hundred lines
> of C++ code messing with Extended MAPI

Will CDO perform any better?

Quote:

> Dmitry Streblechenko
> http://www.dimastr.com/
> OutlookSpy  - Outlook, CDO
> and MAPI Developer Tool




Quote:


> > > Outlook uses Extended MAPI to implement a move operation, namely
> > > IMAPIFolder::CopyMessages() which takes a list of entryids, hence
it
> > does not
> > > need to open each message. Store provider completes the whole
> > operation on the
> > > server without sending lots of data back and forth as apparently
> > happens when
> > > you run your code.

> > But this code problem is happening on a local PC.  If I have
thousands
> > of mail items to process, this could take too long to be feasible.

> > Any other ideas?

Sent via Deja.com
http://www.deja.com/


Tue, 08 Jul 2003 00:02:54 GMT  
 Help: Slow
CDO is at least 10 times faster than the Outlook object model.

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


<snip>

Quote:
> Will CDO perform any better?



Tue, 08 Jul 2003 00:25:02 GMT  
 Help: Slow
Are there any books or resources for programming with CDO?  I have
Outlook 2000 VBA and love it.  Is there anything like this available?

Thanks!



Quote:
> CDO is at least 10 times faster than the Outlook object model.

> --
> Ken Slovak
> [MVP - Outlook]
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
> Appendices, Sams



> <snip>
> > Will CDO perform any better?

Sent via Deja.com
http://www.deja.com/


Tue, 08 Jul 2003 03:06:06 GMT  
 Help: Slow
"Professional CDO Programming"

Dmitry Streblechenko
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

Quote:

> Are there any books or resources for programming with CDO?  I have
> Outlook 2000 VBA and love it.  Is there anything like this available?

> Thanks!



> > CDO is at least 10 times faster than the Outlook object model.

> > --
> > Ken Slovak
> > [MVP - Outlook]
> > Lead Author, Professional Outlook 2000 Programming, Wrox Press
> > Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
> > Appendices, Sams



> > <snip>
> > > Will CDO perform any better?

> Sent via Deja.com
> http://www.deja.com/



Tue, 08 Jul 2003 04:33:50 GMT  
 Help: Slow
I don't think in this particular case CDO will perform any better than Outlook
object model (but I'd love to be proven wrong).
On the low level, there are two ways to move a message:
1. call IMAPIFolder::CopyMessages(<list of entry ids>, ..., MESSAGE_MOVE) -
single call, single RPC, everything is done on the message store side - you can
move as many messages as you want in a single call.
2. create new message in the destination folder, open the message, call
IMessage::CopyTo(<newmessage>), then call IMAPIFolder::DeleteMessages().
The number of calls is 4*N where N is the number of messages you need to move.
Compare to just a single call in #1.

There are no methods on a folder in either CDO or Outlook object model that let
you copy/move multiple messages, there is only MoveTo() on a message, and it is
logical to assume that it is implemented using #1. Obviously I haven't seen the
source code, so all of this is a pure speculation.

Dmitry Streblechenko
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool



Quote:
> CDO is at least 10 times faster than the Outlook object model.

> --
> Ken Slovak
> [MVP - Outlook]
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
> Appendices, Sams



> <snip>
> > Will CDO perform any better?



Tue, 08 Jul 2003 04:44:49 GMT  
 Help: Slow
Oops, I forgot http://www.cdolive.com/

Dmitry Streblechenko
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool


Quote:
> "Professional CDO Programming"

> Dmitry Streblechenko
> http://www.dimastr.com/
> OutlookSpy  - Outlook, CDO
> and MAPI Developer Tool


> > Are there any books or resources for programming with CDO?  I have
> > Outlook 2000 VBA and love it.  Is there anything like this available?

> > Thanks!



> > > CDO is at least 10 times faster than the Outlook object model.

> > > --
> > > Ken Slovak
> > > [MVP - Outlook]
> > > Lead Author, Professional Outlook 2000 Programming, Wrox Press
> > > Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
> > > Appendices, Sams



> > > <snip>
> > > > Will CDO perform any better?

> > Sent via Deja.com
> > http://www.deja.com/



Tue, 08 Jul 2003 04:46:00 GMT  
 Help: Slow
Can't forget Sig <g>

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


Quote:
> Oops, I forgot http://www.cdolive.com/

> Dmitry Streblechenko
> http://www.dimastr.com/
> OutlookSpy  - Outlook, CDO
> and MAPI Developer Tool



Tue, 08 Jul 2003 04:55:13 GMT  
 Help: Slow
No way :-)

Dmitry Streblechenko
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool



Quote:
> Can't forget Sig <g>

> --
> Ken Slovak
> [MVP - Outlook]
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
> Appendices, Sams



Tue, 08 Jul 2003 09:01:30 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. Need Help Slowing Down Access

2. Help: Slow open of document/Template related issue

3. Help - SLOW database updating

4. Help: Slow Binary File Access

5. URGENT !! Pls HELP, Slow and Strange

6. Please help - slow drawing pallette

7. Please help - slow drawing pallette

8. Slow, slow, slow search on VB6, ADO and SS7

9. VB4 is slow..slow....slow

10. Insert into SQL Server slow, slow, slow...

11. SLOW - ADO ASP FOXPRO CDX - SLOW

12. It gets slower and slower.....

 

 
Powered by phpBB® Forum Software