Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Deleting Items in Outlook
Message
From
06/08/2001 15:37:58
 
 
To
06/08/2001 15:14:14
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
00540334
Message ID:
00540350
Views:
12
>Hey--
> I'm trying to write a program that will go through users email accounts (Microsoft Outlook) and delete messages from the Inbox and Deleted Items folders. So far, I have written this code:
>
> loapp=CREATEOBJ('Outlook.Application')
> loSpace=loapp.getnamespace('MAPI')
> mmailbox="Mailbox - "+ALLT(GETE('name')) &&the way that we access specific users accounts
> loInbox=loSpace.GetDefaultFolder(6)
>
> mdelete=MESSAGEBOX("Do you want to delete the messages in the Inbox?",292)
> DO CASE
> CASE mdelete=6
> FOR EACH item in loInbox.items
> item.delete()
> ENDFOR
> CASE mdelete=7
> ENDCASE
>
>which does go through the inbox and begins to delete messages, but it doesn't delete all of them, it always leaves 2 or 3. Just wondering if there is some hole in this code that is causing that and if there is a delete all option or something of the sort for Outlook in VFP.
>
>Thanks
>
>Kent Floros
>Ripon Community Printers

You should start at the end of the collection to the start:
For x=loInbox.Items.Count To 1 Step -1 && etc.
In most collections deleting items with a for each causes the item pointer to be out of sync with the loop.
Previous
Reply
Map
View

Click here to load this message in the networking platform