certem
01-15-2012, 07:45 AM
I use the code below to save the attachments but the date of the attachments become today's date. I want them to stay their original date.
Thank you for your helps.
Public Sub saveAttachtoDisk()
Dim objOL As Outlook.Application
Dim itm As Outlook.MailItem
Dim objAtt As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Dim saveFolder As String
Dim adet As Long
saveFolder = "C:\Users\Ahmet\Desktop\GEÇİCİ\"
Set objOL = CreateObject("Outlook.Application")
Set objSelection = objOL.ActiveExplorer.Selection
adet = 0
For Each itm In objSelection
adet = adet + 1
Set objAtt = itm.Attachments
lngCount = objAtt.Count
For i = lngCount To 1 Step -1
objAtt.Item(i).SaveAsFile saveFolder & adet & objAtt.Item(i).FileName
Next i
Next
MsgBox adet
Set objOL = Nothing
Set objSelection = Nothing
Set objAtt = Nothing
Set itm = Nothing
End Sub
Thank you for your helps.
Public Sub saveAttachtoDisk()
Dim objOL As Outlook.Application
Dim itm As Outlook.MailItem
Dim objAtt As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Dim saveFolder As String
Dim adet As Long
saveFolder = "C:\Users\Ahmet\Desktop\GEÇİCİ\"
Set objOL = CreateObject("Outlook.Application")
Set objSelection = objOL.ActiveExplorer.Selection
adet = 0
For Each itm In objSelection
adet = adet + 1
Set objAtt = itm.Attachments
lngCount = objAtt.Count
For i = lngCount To 1 Step -1
objAtt.Item(i).SaveAsFile saveFolder & adet & objAtt.Item(i).FileName
Next i
Next
MsgBox adet
Set objOL = Nothing
Set objSelection = Nothing
Set objAtt = Nothing
Set itm = Nothing
End Sub