How to save all attachments from multiple emails to folder in Outlook?
As usual, when you receive messages with multiple attachments and you want to save these attachments to a specific folder, you need to save them one by one with some annoying operations. Do you want to get rid of that time-consuming operations and directly save the multiple attachments at once? Please look at the following tutorials.Save all attachments from multiple emails to folder with VBA code
If you don't prefer the VBA method, please try the second method to save all attachments with just several clicks. |
1.
Firstly, you should create a folder for saving the attachments in your
computer. The saving path just like the following screenshot shows, Lj is the user name of the computer, and the Attachments is the folder which you should finally create.
2. After creating the folder, press Alt + F11 to open the Microsoft Visual Basic for Applications window.
3. Then click Insert > Module to open the Module window, and then copy and paste the following VBA code to the window.
VBA code for saving attachments
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
| Public Sub SaveAttachments() 'Update 20141121 Dim objOL As Outlook.Application Dim objMsg As Outlook.MailItem Dim objAttachments As Outlook.Attachments Dim objSelection As Outlook.Selection Dim i As Long Dim lngCount As Long Dim strFile As String Dim strFolderpath As String Dim strDeletedFiles As String strFolderpath = CreateObject( "WScript.Shell" ).SpecialFolders(16) Set objOL = CreateObject( "Outlook.Application" ) Set objSelection = objOL.ActiveExplorer.Selection strFolderpath = strFolderpath & "\Attachments\" For Each objMsg In objSelection Set objAttachments = objMsg.Attachments lngCount = objAttachments.Count strDeletedFiles = "" If lngCount > 0 Then For i = lngCount To 1 Step -1 strFile = objAttachments.Item(i).FileName strFile = strFolderpath & strFile objAttachments.Item(i).SaveAsFile strFile 'objAttachments.Item(i).Delete() If objMsg.BodyFormat <> olFormatHTML Then strDeletedFiles = strDeletedFiles & vbCrLf & "<Error! Hyperlink reference not valid.>" Else strDeletedFiles = strDeletedFiles & "<br>" & "<a href='file://" & _ strFile & "'>" & strFile & "</a>" End If Next i If objMsg.BodyFormat <> olFormatHTML Then objMsg.Body = vbCrLf & "The file(s) were saved to " & strDeletedFiles & vbCrLf & objMsg.Body Else objMsg.HTMLBody = "<p>" & "The file(s) were saved to " & strDeletedFiles & "</p>" & objMsg.HTMLBody End If objMsg.Save End If Next ExitSub: Set objAttachments = Nothing Set objMsg = Nothing Set objSelection = Nothing Set objOL = Nothing End Sub |
Note: This VBA code will permanently remove the attachment from the email.
4. Go to Outlook Mail section to select the emails with attachments which you want to save the attachments.
5. Return to the Microsoft Visual Basic for Applications window, and click button to run the code.
6. When a prompt box showing up, click Allow to save the attachment. Note:
The prompt box’s showing frequencies depend on how many emails you have
selected. If you have selected two emails with attachments, the prompt
box will show up twice and you need to click Allow twice to finish all savings.
7.
After finish all savings, you will see the result as shown in the below
screenshots. You can go to find the saved attachments according to the
saving path or open the attachment directly by just click on the saving
path.
If the VBA code is hard to handle, you can try the following method . |
No comments:
Post a Comment