outlook zip file

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
781
Office Version
  1. 365
Hi,

have this code to just down load zip file but it's downloading all, do i need to change something in the code i created a rule to subject only Weekly AP but is downloading everything.

here is the code:
Code:
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim dateFormat
dateFormat = Format(Now, "yyyy-mm-dd H-mm")


saveFolder = "M:\Navigata\Fin\Gen\Accounts Payable\Weekly AP Invoices\"
For Each objAtt In itm.Attachments
    If InStr(objAtt.DisplayName, ".zip") Then
              objAtt.SaveAsFile saveFolder & "\" & dateFormat & " " & objAtt.DisplayName
         Set objAtt = Nothing
     Next
End Sub

thanks
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
This works for me:

Code:
' Outlook module
Public Sub saveAttachtoDisk(itm As MailItem)
Dim objAtt As Attachment, svFld As String, dateFormat
dateFormat = Format(Now, "yyyy-mm-dd H-mm")
svFld = "d:\pub\"
For Each objAtt In itm.Attachments
    If InStr(objAtt.DisplayName, ".zip") Then _
    objAtt.SaveAsFile svFld & "\" & dateFormat & " " & objAtt.DisplayName
Next
End Sub

Function GetCurrentItem() As Object
Dim objApp As Application
Set objApp = Outlook.Application
Select Case TypeName(objApp.ActiveWindow)
    Case "Explorer"
        Set GetCurrentItem = objApp.ActiveExplorer.Selection.item(1)
    Case "Inspector"
        Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select
Set objApp = Nothing
End Function

Sub Main()
saveAttachtoDisk GetCurrentItem
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,528
Messages
6,125,342
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top