|
Da li neko ima kod pomocu koga bih mogao da sacuvam attachment-e iz mejlova u neki odredjeni folder. Taj kod bi moreo da napravi vise foldera jedan u drugom prema podacima iz maila (posiljaoc\datum\broj\..) i onda da u taj folder sacuva attach. Imam kod pomocu koga mogu da sacuvam attach-e ali bez sortiranja po folderima.
Sub GetAttachments()
On Error GoTo GetAttachments_err
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
i = 0
If Inbox.Items.Count = 0 Then
MsgBox "Nema nijednog pisma koji sadrzi Attachment", vbInformation, "Nothing Found"
Exit Sub
End If
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
FileName = "D:\Attachment\" & Atmt.FileName
Atmt.SaveAsFile FileName
i = i + 1
Next Atmt
Next Item
If i > 0 Then
MsgBox "Nasao sam " & i & "attacment-a" & vbCrLf & "Sacuvao sam ih u folder D:\Attachment\", vbInformation, "Finished!"
Else
MsgBox "Nisam nasao nijedan attachment", vbInformation, "Finished!"
End If
GetAttachments_exit:
Set Atmt = Nothing
Set Item = Nothing
Set ns = Nothing
Exit Sub
GetAttachments_err:
MsgBox "Doslo je do neocekivane greske. Pozovite lokal 7846"
Resume GetAttachments_exit
End Sub
mod: koristi code tagove
|