Using visual basic to access subfolder in Inbox?

后端 未结 3 901
慢半拍i
慢半拍i 2020-12-01 19:41
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace(\"MAPI\")
Set myOlItems = objNS.GetDef         


        
3条回答
  •  春和景丽
    2020-12-01 20:06

    Thats very close :)

    To get all the mail items in a folder called "temp" under the Inbox try this

    Dim olApp As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim olFolder As Outlook.MAPIFolder
    Dim msg As Outlook.MailItem
    
    Set olApp = Outlook.Application
    Set objNS = olApp.GetNamespace("MAPI")
    Set olFolder = objNS.GetDefaultFolder(olFolderInbox)
    Set olFolder = olFolder.Folders("Temp")
    
    For Each msg In olFolder.Items
        Debug.Print msg.Subject
    Next
    

提交回复
热议问题