Я бы сказал, что Office Automation - путь сюда.
Если у вас установлен Excel, вы можете напрямую вставить свойства в ячейки на листе. Вы можете написать макрос в Excel для автоматизации Outlook или вы можете написать макрос в Outlook, чтобы поместить данные в таблицу.
Ниже я создал небольшую часть VBA для внешнего вида и использовал FSO для выполнения грязной работы. Это даст вам скелет для работы, потребуется гораздо больше тестирования обработки ошибок и т. Д. *
Sub SaveItemsToExcel()
On Error GoTo ErrorHandlerExit
Dim oNameSpace As Outlook.NameSpace
Dim oFolder As Outlook.MAPIFolder
'You must set a reference to the Microsoft Scripting Runtime library touse the FileSystemObject
Dim objFS As Scripting.FileSystemObject
Dim objOutputFile As Scripting.TextStream
Set objFS = New Scripting.FileSystemObject
Set objOutputFile = objFS.OpenTextFile("C:\Temp\Export.csv", ForWriting, True)
Set oNameSpace = Application.GetNamespace("MAPI")
Set oFolder = oNameSpace.PickFolder
If oFolder Is Nothing Then
GoTo ErrorHandlerExit
End If
' Check if folder can contain Mail Items
If oFolder.DefaultItemType <> olMailItem Then
MsgBox "Folder does not contain mail messages"
GoTo ErrorHandlerExit
End If
'Write header line
objOutputFile.WriteLine "From,Subject,Recived"
ProcessFolderItems oFolder, objOutputFile
objOutputFile.Close
Set oFolder = Nothing
Set oNameSpace = Nothing
Set objOutputFile = Nothing
Set objFS = Nothing
ErrorHandlerExit:
Exit Sub
End Sub
Sub ProcessFolderItems(oParentFolder As Outlook.MAPIFolder, ByRef objOutputFile As Scripting.TextStream)
Dim oCount As Integer
Dim oMail As Outlook.MailItem
Dim oFolder As Outlook.MAPIFolder
oCount = oParentFolder.Items.Count
For Each oMail In oParentFolder.Items
If oMail.Class = olMail Then
objOutputFile.WriteLine oMail.SenderEmailAddress & "," & oMail.Subject & "," & oMail.ReceivedTime
End If
Next oMail
Set oMail = Nothing
'check to see if we have an child folders
If (oParentFolder.Folders.Count > 0) Then
For Each oFolder In oParentFolder.Folders
ProcessFolderItems oFolder, objOutputFile
Next
End If
End Sub
Марк