No matter how small you think the window of opportunity for something to go wrong, it will. In real time programming, if you can think of it, it usually will happen within milliseconds, no matter how unlikely. ;)
Fred On Fri, Sep 23, 2011 at 9:50 AM, Dave Crozier < [email protected]> wrote: > Fred, > This does work and is more efficient UNLESS you add an item in at the same > time, in which case it fails. I know this is a very, very remote > possibility > but... > > Dave > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On Behalf > Of Fred Taylor > Sent: 23 September 2011 17:23 > To: ProFox Email List > Subject: Re: Automating outlook tasks > > Wouldn't be easier to traverse the items backwards? > > m.nTasks = oTasks.Items.Count > FOR m.xx=m.nTasks to 1 STEP -1 > IF oTasks.Items[m.xx].Subject="#" > otasks.Items[m.xx].Delete() > ENDIF > ENDFOR > > Fred > > > On Fri, Sep 23, 2011 at 6:41 AM, Dave Crozier <[email protected]> > wrote: > > > Steve, > > Me being stupid here. The tasks collection is dynamic so when you delete > an > > entry then the collection changes so you can't traverse simply oonce > through > > it like you are doing. > > > > Each time you delete a task you have to re-initialise the collection and > > traverse again through it, for example: > > > > loOutlook = CREATE("Outlook.Application") > > loNamespace = loOutlook.GetNameSpace("MAPI") > > oTasks = loNameSpace.GetDefaultFolder(13) > > > > nDeletions = 99 > > * > > do while nDeletions<>0 > > nDeletions=0 > > for each loTask in oTasks.Items > > if substr(loTask.Subject,1,1)='#' > > lStatus=loTask.Delete > > nDeletions = nDeletions + 1 > > exit > > endif > > endfor > > enddo > > > > Dave > > [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/cajcbksow97+schda1qq1sqr_uuefpxe2+ecpwehoiwwkd_e...@mail.gmail.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

