Access sub folder in secondary email account

99封情书 提交于 2021-01-29 14:31:22

问题


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.


回答1:


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



回答2:


Figured it out

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


来源:https://stackoverflow.com/questions/58031641/access-sub-folder-in-secondary-email-account

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!