02/09/2024 - @Alex ha scritto:
02/09/2024 - AlbertoL ha scritto:
Grazie 1000
ora ci provo
Cosa provi…?
Perchè non rispondi alle domande in modo compiuto…?
Ti ho chiesto di mostrare il codice che ci consente di capire cosa stai facendo… il codice che ti ho suggerito NON FUNZIONA così, è carente di un pezzo quello che avresti dovuto mostrare.
scusa, eccolo qui
Dim objOL As Outlook.Application
Dim objMsg As Outlook.MailItem 'Object
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Dim strFile As String
Dim strFolderpath As String
Dim strDeletedFiles As String
Dim dtDate As Date
Dim sName As String
Dim nomeFolder As String
Dim sFileType As String
Dim b As Boolean
strFolderpath = CreateObject("WScript.Shell").SpecialFolders(10)
On Error Resume Next
Set objOL = CreateObject("Outlook.Application")
Set objSelection = objOL.ActiveExplorer.Selection
nomeFolder = IIf(ButtonName = "Pul1", "", "\file\")
strFolderpath = strFolderpath & nomeFolder
If Dir(strFolderpath, vbDirectory) = "" Then
MkDir strFolderpath
End If
nomeFolder = "\" & ButtonName & "\"
strFolderpath = strFolderpath & nomeFolder
If Dir(strFolderpath, vbDirectory) = "" Then
MkDir strFolderpath
End If
For Each objMsg In objSelection
Set objAttachments = objMsg.Attachments
lngCount = objAttachments.Count
If lngCount > 0 Then
dtDate = objMsg.SentOn
'dtDate = objMsg.ReceivedDate
sName = Format(dtDate, "ddmmyyyy", vbUseSystemDayOfWeek, vbUseSystem) & "_" & Format(dtDate, "hhnnss", vbUseSystemDayOfWeek, vbUseSystem) & “-”
For i = lngCount To 1 Step -1
b = False
strFile = sName & objAttachments.Item(i).FileName
sFileType = LCase$(Right$(strFile, 4))
Select Case sFileType
Case ".MSG", ".Msg", ".msg"
If ButtonName = "Pul1" Then
b = True
End If
Case ".PDF", ".Pdf", ".pdf"
b = True
End Select
If b = True Then
strFile = strFolderpath & i & strFile
objAttachments.Item(i).SaveAsFile strFile
End If
Next i
End If
Next
ExitSub:
Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing