我創建了一個小程序將我的電子郵件保存到Windows文件夾。Outlook應用程序 - 無法獲取文件夾列表
我無法檢索Outlook文件夾列表。
當我檢查我是否選擇了收件箱文件夾,它不是!
Dim app As Outlook.Application
Dim ns As Outlook.NameSpace
Dim siFolder As Outlook.Folder
Dim Annee As Integer
Dim Mois As Integer
Dim Jour As Integer
app = New Outlook.Application()
ns = app.Session
siFolder = CType(ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox), Outlook.Folder) 'I select here the Inbox Folder
' I do a test, but siFolder.name appears not to be the inbox folder !!
If siFolder.Name Is ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) Then
Annee = Format(mailitem.ReceivedTime, "yyyy")
Mois = Format(mailitem.ReceivedTime, "MM")
Jour = Format(mailitem.ReceivedTime, "dd")
ElseIf siFolder Is ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail) Then
Annee = Format(mailitem.SentOn, "yyyy")
Mois = Format(mailitem.SentOn, "MM")
Jour = Format(mailitem.SentOn, "dd")
Else
MsgBox("Aucune boite sélectionnée")
End 'because i can't select the Inbox, application ends here.
End If
創造了VB的對象引用時,不要你需要使用「設置」關鍵詞。淨?它應該是'** Set ** app =新Outlook.Application'和'** Set ** ns = app.Session' – JimmyPena