Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in




Kutools for Outlook: 100+ New Advanced Tools for Outlook.
Office Tab: Enable Tabbed Editing and Browsing in Office, Just Like Chrome, Firefox, IE 8/9/10.
Classic Menu: Bring Old Menus and Toolbars Back to Office 2007, 2010, 2013, 2016 and 2019.

arrow blue right bubble 運行VBA將多封郵件中的附件批量保存到資料夾中

1. 首先,在電腦裡創建一個將要保存附件的資料夾。資料夾路徑應如下圖所示:MarsPC是windows用戶名,Attachments為資料夾名。

2. 創建資料夾後,回到Outlook介面,按住鍵盤上的Alt 和F11鍵打開Microsoft Visual Basic for Applications視窗。

3. 點擊插入 > 模組打開模組視窗,然後將下面VBA代碼粘貼到新打開的模組視窗裡。


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
                If objMsg.BodyFormat <> olFormatHTML Then
                    strDeletedFiles = strDeletedFiles & vbCrLf & "<Error! Hyperlink reference not valid.>"
                    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
                    objMsg.HTMLBody = "<p>" & "The file(s) were saved to " & strDeletedFiles & "</p>" & objMsg.HTMLBody
                End If
            End If
        Set objAttachments = Nothing
        Set objMsg = Nothing
        Set objSelection = Nothing
        Set objOL = Nothing
    End Sub

4. 打開Outlook的郵件視圖,選中帶附件郵件。

5. 返回Microsoft Visual Basic for Applications視窗,點擊運行按鈕(或者點擊F5鍵)運行代碼。

6. 當下圖所示對話方塊彈出時,點擊Allow按鈕。


7. 所有附件保存成功後,最後的保存結果如下圖所示。你可以點擊對應的保存路徑找到已保存的附件。

arrow blue right bubble 運行Kutools for Outlook快速地將多封郵件中的附件保存到資料夾中

Kutools for Outlook的拆離所有功能可以幫你在Outlook裡快速地保存多封郵件裡的附件。

Kutools for Outlook - 讓你在 Outlook 裡的工作更簡單、更快捷!批量保存/壓縮附件、高級列印、自動答覆\轉發\攔截垃圾郵件、刪除重複項,等等……

1. 打開郵件資料夾,在郵寄清單裡選擇多封帶附件的郵件。

2. 點擊Kutools > 其他功能 > 拆離所有。見下圖:

3. 在拆離所有對話方塊裡,點擊


注意:第一次運行該功能時,點擊Kutools > 其他功能 > 拆離所有後會彈出流覽資料夾對話方塊,你需要在此對話方塊裡指定保存附件的資料夾。

點擊下載 Kutools for Outlook, 45天無限制免費試用!


Recommended Productivity Tools

shot kutools outlook kutools tab 1180x121
shot kutools outlook kutools plus tab 1180x121

Kutools for Outlook - More than 100 Advanced Functions for Outlook, Improve 70% Efficiency For you

  • Complicated and repeated operations can be done a one-time processing in seconds.
  • Forward multiple emails individually with one-click, and auto forward by rules.
  • Auto CC/BCC every sending email and easy for customizing rules, and auto reply without requiring exchange server.
  • Powerful junk emails filter, remove duplicate emails, reply with attachment, bunch of one-click operations, and so on...
  • 60-day unlimited free trial. 60-day money back guarantee. 2 years free upgrade and support. Buy once, use forever.
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.