outlook zip file

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
784
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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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