
Why only half of the messages??
You're seeing that behavior because of the way looping works when you're
deleting items. I typically see this behavior when using a For i - 1 to
Items.Count loops however.
Try using
while oFolder.Items.Count > 0
'Code
wend
--
Patricia Cardoza
Outlook MVP
www.cardozasolutions.com
~Please post all replies to the newsgroup~
Quote:
> When I run the script below, why does it only run through half of the
> messages rather than the whole bunch? If I remove the DELETE
> notation, it works on all messages. I have to run this 5 times on a
> folder full of messages until they're all done.
> Anyone have any ideas? I'm running Microsoft Outlook 2000 SR-1 w/
> Microsoft Visual Basic 6.3
> ---start---
> Sub ReportSave()
> Dim oApp As Application
> Dim oNS As NameSpace
> Dim oMsg As Object
> Dim oAttachments As Outlook.Attachments
> Dim strControl
> Dim myString
> Set oApp = New Outlook.Application
> Set oNS = oApp.GetNamespace("MAPI")
> Set myFolder = oNS.GetDefaultFolder(olFolderInbox)
> Set oFolder = myFolder.Folders("Change Memos")
> strControl = 0
> For Each oMsg In oFolder.Items
> With oMsg
> myString = Replace(oMsg, "/", "-")
> oMsg.Attachments.Item(1).SaveAsFile "C:\reports\in\"
> & myString & ".rtf"
> .Delete
> End With
> Next
> End Sub
> ---stop---
> Thanks for any help.
> Joe C.