Я создал небольшую программу для сохранения своих электронных писем в папке Windows.
Я не могу получить список папок 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