Hi Guys


I have written following code and it works fine if the 'Completed' folder is within My Inbox (Personnel folder) but in my outlook there are some other group folders as well so if I create 'Completed' folder within the group folder then the below code doesn't work. So I am looking for VBA code that will check the parent folder and if its 'My inbox' then move the email from there to 'Completed' folder within that.


And if the parent folder is different then move selected email to 'Completed' folder within that.


Sub ProcessSelection()
Dim olMailItem As Object
      If Application.ActiveExplorer.Selection.Count = 0 Then
        MsgBox "No Items selected!", vbCritical, "Error"
        Exit Sub
    End If
    On Error Resume Next
    For Each olMailItem In Application.ActiveExplorer.Selection
             SaveAttachments olMailItem
           DoEvents
    Next olMailItem
Err_Handler:
    Set olMailItem = Nothing
lbl_Exit:
    Exit Sub
End Sub
Private Sub SaveAttachments(olItem As Object)
Set myNameSpace = Application.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myInbox.Items
Set myDestFolder = myInbox.Folders("Completed")
olItem.Move myDestFolder
Set olItem = myItems.FindNext
olItem.Move myDestFolder
Set olItem = myItems.FindNext