我打开Outlook并引用一个文件夹。如何获得对话框以手动选择文件夹中的电子邮件项目?
Dim oOlApp As Object, objNmSpc As Object, ofldr As Object
On Error Resume Next
Set oOlApp = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
Set oOlApp = CreateObject("Outlook.Application")
End If
Err.Clear
On Error GoTo 0
Set objNmSpc = oOlApp.GetNamespace("MAPI")
Set ofldr = objNmSpc.PickFolder
If Not ofldr Is Nothing Then MsgBox ofldr
答案 0 :(得分:1)
您可以循环浏览所选文件夹中的每个项目,如下所示......
Dim oItem As Object
For Each oItem In ofldr.Items
Debug.Print oItem.SenderName, oItem.Subject, oItem.ReceivedTime
Next oItem