|
|
MS OutLook - Вывод списка элементов папки в Immediate Window
Просто как пример работы с приложением ....
Private Sub GetOutlookItems()
Dim OutLookApp As Object
Dim OutLookNameSpace As Object
Dim OutLookFolder As Object
Dim OutLookItems As Object
Dim OutLookItem As Object
Dim iCount%, sVal$
On Error GoTo GetOutlookContacts_Err
Set OutLookApp = CreateObject("Outlook.Application")
Set OutLookNameSpace = OutLookApp.GetNamespace("MAPI")
Set OutLookFolder = OutLookNameSpace.GetDefaultFolder(6)
Set OutLookItems = OutLookFolder.Items
iCount = OutLookItems.Count
OutLookItems.Sort "SenderName", False
For Each OutLookItem In OutLookItems
sVal = ""
With OutLookItem
sVal = sVal & .EntryID & "; "
sVal = sVal & .Subject & ";"
sVal = sVal & .SenderName & ";"
sVal = sVal & CDate(.ReceivedTime) & ";"
End With
Debug.Print sVal
Next
Debug.Print String(80, "-")
GetOutlookContacts_End:
On Error Resume Next
OutLookApp.Quit
Set OutLookFolder = Nothing
Set OutLookApp = Nothing
Set OutLookItem = Nothing
Set OutLookItems = Nothing
Set OutLookNameSpace = Nothing
Err.Clear
Exit Sub
GetOutlookContacts_Err:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in sub GetOutlookContacts.", _
vbCritical, "Произошла ошибка!"
Debug.Print "GetOutlookContacts_Line: " & Erl & "."
Err.Clear
Resume GetOutlookContacts_End
End Sub
|
|