Microsoft Office Tutorials and References
In Depth Information
Saving E-mail Attachments in a Specified Folder
Saving E-mail Attachments in a Specified Folder
This macro saves all e-mail attachments in the active Outlook folder into the
specified folder. It automatically renames the saved files in the folder by
producing auto-incremented version numbers.
Scenario: You sent out a questionnaire to 1,000 employees
in the company in the form of a Word document. You
received all the responses back as Word document
attachments. The attachments all have the same name. You
know that this topic provides code to extract data from Word
forms, but you can’t figure out how to quickly get all the
documents saved from the e-mails into a folder so you can
use that macro. This entry solves your dilemma.
View the Appendix to learn how to store this procedure
in a Standard module.
Option Explicit¶
' * * * * *¶
Public Sub SaveAttachments()¶
'Outlook Application Objects declaration¶
Dim objApp As Outlook.Application¶
Dim objFolder As Outlook.MAPIFolder¶
Dim objItem As Object¶
Dim itemAttc As Outlook.Attachment¶
'FileSystemObject Objects declaration¶
Dim fso As Object 'FileSystemObject¶
Dim fld As Object 'Folder¶
Dim fil As Object 'File¶
Dim i As Long 'Counter¶
'Array variable to store file name and extension¶
Dim strFileName() As String¶
On Error GoTo ErrHandler¶
'Create FileSystemObject object¶
Set fso = CreateObject("Scripting.FileSystemObject")¶
Search JabSto ::

Custom Search