0
votes

I am trying to move emails from the inbox in a secondary Outlook account to a sub-folder in that account.

Sub newBox()
    Dim myInbox As Outlook.Folder
    Dim myDestFolder As Outlook.Folder
    Dim myItems As Outlook.Items
    Dim myItem As Object
    Dim i As Integer

    Set myInbox = Session.Folders("Secondary").Folders("Inbox")
    Set myDestFolder = myInbox.Parent.Folders("Complete")

End Sub

When I try to set the destination, myDestFolder, I get

Run-Time error, An object could not be found.

2

2 Answers

1
votes

You navigated the folder tree from Secondary to Inbox then back to myInbox.Parent which is Secondary.

In your answer post you changed to

Set myDestFolder = Session.Folders("Secondary").Folders("Inbox").Folders("Complete")

This indicates the Complete folder is immediately under the Inbox.

Sub newBox()

    Dim myInbox As Folder
    Dim myDestFolder As Folder

    Set myInbox = Session.Folders("Secondary").Folders("Inbox")
    Set myDestFolder = myInbox.Folders("Complete")

End Sub
0
votes

Figured it out

Set myDestFolder = Session.Folders("Secondary").Folders("Inbox").Folders("Complete")