Creating a CDO collection from an Outlook collection 
Author Message
 Creating a CDO collection from an Outlook collection

How can I create a CDO Messages collection from an Outlook Items collection?

"Set objCDOMessages = objOutlookItems" will of course generate a "Type
mismatch" error.

Gerwin.



Sun, 25 Jan 2004 18:57:21 GMT  
 Creating a CDO collection from an Outlook collection
Get the EntryID and StoreID of the MAPIFolder that the Items
collection is in and then get that Folder in CDO using the
Session.GetFolder method. Then get its Messages collection.

--
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:
> How can I create a CDO Messages collection from an Outlook Items
collection?

> "Set objCDOMessages = objOutlookItems" will of course generate a
"Type
> mismatch" error.

> Gerwin.



Mon, 26 Jan 2004 21:31:14 GMT  
 Creating a CDO collection from an Outlook collection
I don't want to get a CDO collection of all folder messages but only from
those after a (Outlook) Restrict call.

    Set objSelection = objFolder.Items.Restrict("[myField] = '123'")
    ' create here a CDO collection from the Outlook object "objSelection"
(but how...)

Gerwin.



Quote:
> Get the EntryID and StoreID of the MAPIFolder that the Items
> collection is in and then get that Folder in CDO using the
> Session.GetFolder method. Then get its Messages collection.

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



> > How can I create a CDO Messages collection from an Outlook Items
> collection?

> > "Set objCDOMessages = objOutlookItems" will of course generate a
> "Type
> > mismatch" error.

> > Gerwin.



Mon, 26 Jan 2004 21:54:39 GMT  
 Creating a CDO collection from an Outlook collection
You can't do that. The collection you get exists only in your Outlook
collection object. You can get the entire collection in CDO and then
use the MessageFilter object of the collection to restrict it to the
items you want.

The only other way would be to iterate over the entire Outlook
restricted collection, get each item and it's EntryID, get the item as
a CDO item and then add it to a Collection object. Not very practical
and it would take a heck of a lot longer than just using a CDO
MessageFilter on the entire CDO collection.

--
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:
> I don't want to get a CDO collection of all folder messages but only
from
> those after a (Outlook) Restrict call.

>     Set objSelection = objFolder.Items.Restrict("[myField] = '123'")
>     ' create here a CDO collection from the Outlook object
"objSelection"
> (but how...)

> Gerwin.



Tue, 27 Jan 2004 22:40:13 GMT  
 Creating a CDO collection from an Outlook collection
Ok, but with a CDO MessageFilter I can't use a 'bigger than' or 'smaller
than' comparison. That's my problem...
Gerwin.



Quote:
> You can't do that. The collection you get exists only in your Outlook
> collection object. You can get the entire collection in CDO and then
> use the MessageFilter object of the collection to restrict it to the
> items you want.

> The only other way would be to iterate over the entire Outlook
> restricted collection, get each item and it's EntryID, get the item as
> a CDO item and then add it to a Collection object. Not very practical
> and it would take a heck of a lot longer than just using a CDO
> MessageFilter on the entire CDO collection.

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



> > I don't want to get a CDO collection of all folder messages but only
> from
> > those after a (Outlook) Restrict call.

> >     Set objSelection = objFolder.Items.Restrict("[myField] = '123'")
> >     ' create here a CDO collection from the Outlook object
> "objSelection"
> > (but how...)

> > Gerwin.



Thu, 29 Jan 2004 14:42:13 GMT  
 Creating a CDO collection from an Outlook collection
No, you would have to use equality as your operator.

--
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:
> Ok, but with a CDO MessageFilter I can't use a 'bigger than' or
'smaller
> than' comparison. That's my problem...
> Gerwin.



Sun, 01 Feb 2004 04:26:58 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. CDO & Outlook-Out of memory, messages collection

2. Can't Create a New Field with CDO Collections

3. Collections, Collections and More Collections

4. CDO InfoStore Public Folders can not see Fields Collection

5. CDO - Message Object - Fields collection

6. MAPI/CDO Recipients collections

7. CDO Collection Limit

8. Links collection using CDO

9. CDO Collection

10. Document collections and AllForms collections

11. using collection of collections

12. Storing a collection in a collection

 

 
Powered by phpBB® Forum Software