Hey everyone. Wondering if someone could help me get my code fixed up. I'm trying to create code that will enable me to extract ".zip" files from Outlook from a specified folder.
So far I have managed to get my code to retrieve all attachments from my inbox and put them in a folder on my PC.
I'm just wondering if anyone has any ideas of how I could change this code to obtain attachments from a specified mailbox folder...and only get ".zip" attachments.
I simply put the code below into a project and run it, it does the job...Any help appreciated, thanks
Code:Private Sub Form_Load() Dim oOutlook As Outlook.Application Dim oNs As Outlook.Namespace Dim oFldr As Outlook.MAPIFolder Dim oAttachments As Outlook.Attachments Dim oAttachment As Outlook.Attachment Dim iMsgCount As Integer Dim oMessage As Outlook.MailItem Dim iCtr As Long, iAttachCnt As Long Dim sFileNames As String Dim aFileNames() As String 'get reference to inbox Set oOutlook = New Outlook.Application Set oNs = oOutlook.GetNamespace("MAPI") Set oFldr = oNs.GetDefaultFolder(olFolderInbox) For Each oMessage In oFldr.Items With oMessage 'reference and save all attachments With oMessage.Attachments iAttachCnt = .Count If iAttachCnt > 0 Then For iCtr = 1 To iAttachCnt .Item(iCtr).SaveAsFile "C:\INPUT\" & .Item(iCtr).FileName Next iCtr End If End With End With DoEvents Next




Reply With Quote