Accessing Outlook - Enumerate error 
Author Message
 Accessing Outlook - Enumerate error

The code below searches and collects a list of Appointment from Outlook
where the [mileage] field contains '1-202' (I used the mileage field
because it was spare.

Using this bit of code, the line with the wait window execute OK
indicating 2 items found (as expected).  However when I try to display
them using tha last 3 line of code, I get the error - 'numitems cannot
be enumerated'

I pinched the last 3 lines from a Visual Basic example, does anyone know
the equivalent Foxpro 5.0 code?

It is very frustrating as the code has located the items but I can't
work out how to access them.

Dave Swift

objOutlook = createobject ('Outlook.Application')
objNamespace = objOutlook.GetNamespace('MAPI')
* reference the Calendar Folder
objFolder = objNamespace.GetDefaultFolder(9)

numitems=objFolder.Items
myclause="[mileage] = '1-202'"
Item=numitems.restrict(myclause)

wait window str(Item.count)

for each myitem in numitems
        myitem.display
next



Sun, 24 Mar 2002 03:00:00 GMT
 Accessing Outlook - Enumerate error

Webmaster,
For the last three lines:
for each myitem in item && assuming you want restricted set
   *myitem.display This will display the entire calender entry
   ? myitem.Subject
   ? myitem.Location
   ? myitem.Start
   * etc.
endfor && "next" will work but EndFor is more "correct"

This works in VFP 5.0a under Win98SE w/ OL 97, and WinNT w/ OL2000

Rick


Quote:
> The code below searches and collects a list of Appointment from Outlook
> where the [mileage] field contains '1-202' (I used the mileage field
> because it was spare.

> Using this bit of code, the line with the wait window execute OK
> indicating 2 items found (as expected).  However when I try to display
> them using tha last 3 line of code, I get the error - 'numitems cannot
> be enumerated'

> I pinched the last 3 lines from a Visual Basic example, does anyone know
> the equivalent Foxpro 5.0 code?

> It is very frustrating as the code has located the items but I can't
> work out how to access them.

> Dave Swift

> objOutlook = createobject ('Outlook.Application')
> objNamespace = objOutlook.GetNamespace('MAPI')
> * reference the Calendar Folder
> objFolder = objNamespace.GetDefaultFolder(9)

> numitems=objFolder.Items
> myclause="[mileage] = '1-202'"
> Item=numitems.restrict(myclause)

> wait window str(Item.count)

> for each myitem in numitems
> myitem.display
> next



Sun, 24 Mar 2002 03:00:00 GMT
 Accessing Outlook - Enumerate error
First, I'd kill off these four lines:
 define class objOutlook as outlook.application
 define class objcont as outlook.ContactItem
 define class objnamespace as outlook.NameSpace
 define class objmyitems as outlook.Folder
They are definitely not VFP syntax, and I'm not sure what they may be doing
in the intrepretation of the later code.

Also, you didn't indicate that you were using 5.0a, if not, go to
http://msdn.microsoft.com/vstudio/sp/vs97/default.asp and download the Core
update, or order the CD.
Last, even though Item isn't a VFP reserved word, it is an property of the
Outlook object, try:
loItem=numitems.restrict(myclause)
etc., instead.

Rick

*

* Rick,
*
* Thanks for taking the time to answer my query. I tried your suggested
*change nut still get the dreaded 'cannot enumerate error'.
 *Below is the code and an example to find one appointment and display it
*which does work OK. I am using VFP 5.0 and Outlook 98.
*
*Any other help or example VFP code would be greatly appreciated.
*
******This code is in main program startup
*
*define class objOutlook as outlook.application
*define class objcont as outlook.ContactItem
*define class objnamespace as outlook.NameSpace
*define class objmyitems as outlook.Folder
*
*
*******This code is on the form button click
*
*objOutlook = createobject ('Outlook.Application')
*objNamespace = objOutlook.GetNamespace('MAPI')
** reference the Calendar Folder
*objFolder = objNamespace.GetDefaultFolder(9)
*
** Get the StoreID, which is a property of the folder.
*StoreID = objFolder.StoreID
*
*numitems=objFolder.Items
*myclause="[mileage] = '1-202'"
*Item=numitems.restrict(myclause)
*
*wait window str(Item.count)
*for each myitem in Item       <------------program stops here
* Item.display             with ITEM cannot be enumerated
*endfor
*
*
*
******* This example works OK and displays an Appointment called 'Test'
*objOutlook = createobject ('Outlook.Application')
*objNamespace = objOutlook.GetNamespace('MAPI')
** reference the Calendar Folder
*objFolder = objNamespace.GetDefaultFolder(9)
*
** Get the StoreID, which is a property of the folder.
*      StoreID = objFolder.StoreID
*
*numitems=objFolder.Items.count
*Item=objFolder.Items("Test")
*
*if found = .t. then
* Item.display
*
*else
* wait window 'None Found'
*endif
*

Quote:
> Webmaster,
> For the last three lines:
> for each myitem in item && assuming you want restricted set
>    *myitem.display This will display the entire calender entry
>    ? myitem.Subject
>    ? myitem.Location
>    ? myitem.Start
>    * etc.
> endfor && "next" will work but EndFor is more "correct"

> This works in VFP 5.0a under Win98SE w/ OL 97, and WinNT w/ OL2000

> Rick



Mon, 25 Mar 2002 03:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Access report to Outlook/ Open Outlook and mail report

2. MS Data Link Error: Error enumerating data servers

3. Problem linking accessing Outlook from ODBC via Access

4. accessing outlook from vc (via access mdb file)

5. Enumerating DB Access

6. Enumerated field access thru CRecordset-derived class

7. Enumerating the tables in an Access 2000 database

8. How to consecutively enumerate a field in MS-Access QBE

9. please help: Error enumerating data servers

10. error enumerating data servers for VB.NET

11. 'Can Not enumerate deletion' Error

12. sp3 merge error: Failed to enumerate changes in the filtered articles fix - Thanks Microsoft


 
Powered by phpBB® Forum Software