Loop gets limited (1 Viewer)

two things..
it still stopped import after the 16th item, when there was 17 in total.
Also, it throws an error at .Name
 
Well you need to look at what you could use to give a different filename each time.
If it is early bound. You can step through the properties with intellisense.

Again, walk your code. :(
 
Last edited:
This morning there was only one item so I was unable to recreate the error. But this is my code, which stopped after the 16th item yesterday.
Code:
Set OlItems = MYFOLDER.Items
    
    'For Each olMail In OlItems
        y = olMail.Count
        Do Until y = 0
            If olMail.subject Like "*Proceeding ID*" Then
                strFile = olMail & ".XML"
                strFile = strFolderpath & strFile
                If olMail.Attachments.Count > 0 Then
                    'For x = 1 To olMail.Attachments.Count
                        x = olMail.Attachments.Count
                        Do Until x = 0
                            'olMail.Attachments.Item(x).SaveAsFile strFile
                             strFile = strFolderpath & olMail.Attachments.Item(x).Name
                             olMail.Attachments.Item(x).SaveAsFile strFile
                             x = x - 1
                        Loop
                    'Next x
                    
                    subject = olMail.subject
                    sreplace = "_"
                    subject = Replace(subject, " ", sreplace)
                    olMail.Body = olMail.Body & vbCrLf & "The file was processed " & Now()
                    olMail.subject = "Processed - " & subject
                    olMail.Move objDestfolder
                    'olMail.Save
    
                End If
            End If
            y = y - 1
        Loop
    'Next
 
    Set olMail = Nothing
    Set olApp = Nothing
 
If it processed 1 then it processed the first and the last. Send yourself three emails. Open the code and step through it as each email is processed so you find the problem.
 

Users who are viewing this thread

Back
Top Bottom