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