5
我工作在一個Outlook VBA應用程序,我需要訪問我的收件箱,但我似乎遇到了一些麻煩。我正在使用GetDefaultFoldder(olFolderInbox)
方法,但是,我有幾個電子郵件地址設置,並沒有出現在我的個人文件夾的收件箱中。訪問Outlook默認文件夾
所以我的問題是,這個默認文件夾定義在哪裏?我如何知道哪個收件箱是默認收件箱?我知道也有GetFolderFromID
方法,如果我要使用這個,
如何找到文件夾ID以指向它?
這是我使用的代碼。這是來自Timothy Chen Allen博客的教程,如Timothy's Blog所示。代碼:
Sub find_unread()
On Error GoTo eh:
Dim ns As Outlook.NameSpace
Dim folder As MAPIFolder
Dim item As Object
Dim msg As MailItem
Set ns = Session.Application.GetNamespace("MAPI")
Set folder = ns.GetDefaultFolder(olFolderInbox)
For Each item In folder.Items
DoEvents
If (item.Class = olMail) And (item.UnRead) Then
Set msg = item
Debug.Print msg.SenderEmailAddress
msg.Display True
End If
Next
MsgBox "All messages in Inbox are read", vbInformation, "All Read"
Exit Sub
eh:
MsgBox Err.Description, vbCritical, Err.Number
End Sub
建議您發佈您的實際代碼 – 2011-05-24 02:16:48