Last active
April 25, 2016 17:12
-
-
Save vinnyp/d6a26b969bb5e1d5395f4e2c9c3d12eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ' Outlook VBA Script to download all attachments (including embedded attachments) from a specific folder. | |
| ' Items will be downloaded into a folder you specify. | |
| Sub downloadallattachments() | |
| 'Folder Constants | |
| Const olFolderCalendar = 9 | |
| Const olFolderContacts = 10 | |
| Const olFolderDeletedItems = 3 | |
| Const olFolderDrafts = 16 | |
| Const olFolderInbox = 6 | |
| Const olFolderJournal = 11 | |
| Const olFolderJunk = 23 | |
| Const olFolderNotes = 12 | |
| Const olFolderOutbox = 4 | |
| Const olFolderSentMail = 5 | |
| Const olFolderTasks = 13 | |
| Const olPublicFoldersAllPublicFolders = 18 | |
| Const olFolderConflicts = 19 | |
| Const olFolderLocalFailures = 21 | |
| Const olFolderServerFailures = 22 | |
| Const olFolderSyncIssues = 20 | |
| Set objOutlook = CreateObject("Outlook.Application") | |
| Set objNamespace = objOutlook.GetNamespace("MAPI") | |
| Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox) | |
| Set colItems = objFolder.Items | |
| Set objFSO = CreateObject("Scripting.FileSystemObject") | |
| For Each objMessage In colItems | |
| intCount = objMessage.Attachments.Count | |
| If intCount > 0 Then | |
| For i = 1 To intCount | |
| strTempFile = objFSO.GetTempName | |
| objMessage.Attachments.Item(i).SaveAsFile "C:\attachments\" & strTempFile & "_" & _ | |
| objMessage.Attachments.Item(i).FileName | |
| Next | |
| End If | |
| Next | |
| End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment