в сети нашелся отличный макрос который вытягивает аттачи из писем Outlook, но только из почтового ящика на локальной машине.
В Outlook (на работе) создан еще Сетевой архив Outlook и есть архивы pst, сохраненные на локальной машине.
как сделать так что бы этот макрос и эти архивы видел, особенно сетевой нужен. спасибо
подозреваю что надо что то дописать в этих строчках:
Код |
---|
Set ol = New Outlook.Application
Set ns = ol.GetNamespace("MAPI")
Set fol = ns.Folders(1).Folders("123") |
Код |
---|
Sub SaveOutlookAttachments()
'This early-binding version requires a reference to the Outlook and Scripting Runtime object libraries
Dim ol As Outlook.Application
Dim ns As Outlook.Namespace
Dim fol As Outlook.Folder
Dim i As Object
Dim mi As Outlook.MailItem
Dim at As Outlook.Attachment
Dim fso As Scripting.FileSystemObject
Dim dir As Scripting.Folder
Dim dirName As String
Set fso = New Scripting.FileSystemObject
Set ol = New Outlook.Application
Set ns = ol.GetNamespace("MAPI")
Set fol = ns.Folders(1).Folders("123")
For Each i In fol.Items
If i.Class = olMail Then
Set mi = i
If mi.Attachments.Count > 0 Then
'Debug.Print mi.SenderName, mi.ReceivedTime, mi.Attachments.Count
dirName = _
"D:\Outlook Files\" '& _
' Format(mi.ReceivedTime, "yyyy-mm-dd hh-nn-ss ") & _
' Left(Replace(mi.Subject, ":", ""), 10)
If fso.FolderExists(dirName) Then
Set dir = fso.GetFolder(dirName)
Else
Set dir = fso.CreateFolder(dirName)
End If
For Each at In mi.Attachments
Debug.Print vbTab, at.DisplayName, at.Size
at.SaveAsFile dir.Path & "\" & at.Filename
Next at
End If
End If
Next i
End Sub |