Skip to main content

如何在Outlook中刪除郵件中的所有附件?

Author: Kelly Last Modified: 2025-05-12

通常,當您預覽郵件時,可以右鍵單擊並選擇「刪除附件」選項來刪除附件。有時候一封郵件中可能會有很多附件,逐一手動刪除會非常繁瑣。這裡我們為您提供兩個簡單的方法,幫助您一次性刪除一封郵件中的所有附件,甚至還能刪除多封郵件中的所有附件。

手動刪除Outlook中一封郵件的所有附件
使用VBA代碼刪除Outlook中多封郵件的所有附件
使用Kutools for Outlook輕鬆刪除一封或多封郵件中的所有附件


手動刪除Outlook中一封郵件的所有附件

利用Outlook中的「刪除附件」功能,可以輕鬆刪除所選郵件中的所有附件。

步驟 1:選擇您稍後要刪除附件的郵件。

步驟 2:點擊閱讀窗格中的任意一個附件以啟用附件工具。

doc-save-attachments-1

步驟 3:在「附件」選項卡的「區域 」組中,點擊「全選」按鈕。

doc-save-attachments-2

此步驟將讓您一次性選擇該郵件中的所有附件。

步驟 4:在「附件」選項卡的「操作」組中,點擊「刪除附件」按鈕。

步驟 5:在警告對話框中,點擊「刪除附件」按鈕。

doc-save-attachments-3

然後,這封所選郵件中的所有附件將立即被刪除。

備註:「刪除附件」功能在Outlook 2010及更高版本中運行良好,但在Outlook 2007中不適用。


輕鬆刪除Outlook中多封所選郵件的所有附件:

借助Kutools for Excel的「拆解所有附件」工具,您可以輕鬆刪除多封所選郵件中的所有附件,如下方示範所示。(附件將保存到指定文件夾)立即下載並試用!(30-天免費試用)


使用VBA代碼刪除Outlook中多封郵件的所有附件

如果您想刪除Microsoft Outlook中多封郵件的所有附件,以下方法將幫助您輕鬆完成。我們建議您首先在Microsoft Outlook中啟用所有宏

步驟 1:進入「我的文檔」文件夾,創建一個新文件夾,並將其命名為OLAttachments

步驟 2:選擇您稍後要刪除附件的多封郵件。

備註:您可以按住Ctrl 鍵並點擊來選擇不連續的郵件。

您可以按住Shift 鍵並點擊來選擇連續的郵件。

步驟 3:同時按下Alt鍵和F11鍵打開VBA編輯器。

步驟 4:在左側欄中展開Project1 > Microsoft Outlook Objects,然後雙擊ThisOutlookSession以在編輯器中打開它。請參見以下截圖:

doc-delete-attachments-4

步驟 5:複製並將以下VBA代碼粘貼到編輯窗格中。

Public Sub ReplaceAttachmentsToLink()
Dim objApp As Outlook.Application
Dim aMail As Outlook.MailItem 'Object
Dim oAttachments As Outlook.Attachments
Dim oSelection As Outlook.Selection
Dim i As Long
Dim iCount As Long
Dim sFile As String
Dim sFolderPath As String
Dim sDeletedFiles As String
 
    ' Get the path to your My Documents folder
    sFolderPath = CreateObject("WScript.Shell").SpecialFolders(16)
    On Error Resume Next
 
    ' Instantiate an Outlook Application object.
    Set objApp = CreateObject("Outlook.Application")
 
    ' Get the collection of selected objects.
    Set oSelection = objApp.ActiveExplorer.Selection
 
    ' Set the Attachment folder.
    sFolderPath = sFolderPath & "\OLAttachments"
 
    
    ' Check each selected item for attachments. If attachments exist,
    ' save them to the Temp folder and strip them from the item.
    For Each aMail In oSelection
 
    ' This code only strips attachments from mail items.
    ' If aMail.class=olMail Then
    ' Get the Attachments collection of the item.
    Set oAttachments = aMail.Attachments
    iCount = oAttachments.Count
     
       
    If iCount > 0 Then
     
        ' We need to use a count down loop for removing items
        ' from a collection. Otherwise, the loop counter gets
        ' confused and only every other item is removed.
         
        For i = iCount To 1 Step -1
         
            ' Save attachment before deleting from item.
            ' Get the file name.
            sFile = oAttachments.Item(i).FileName
             
            ' Combine with the path to the Temp folder.
            sFile = sFolderPath & "\" & sFile
             
            ' Save the attachment as a file.
            oAttachments.Item(i).SaveAsFile sFile
             
            ' Delete the attachment.
            oAttachments.Item(i).Delete
             
            'write the save as path to a string to add to the message
            'check for html and use html tags in link
            If aMail.BodyFormat <> olFormatHTML Then
                sDeletedFiles = sDeletedFiles & vbCrLf & "<file://" & sFile & ">"
            Else
                sDeletedFiles = sDeletedFiles & "<br>" & "<a href='file://" & _
                sFile & "'>" & sFile & "</a>"
            End If
             
                         
        Next i
        'End If
             
       ' Adds the filename string to the message body and save it
       ' Check for HTML body
       If aMail.BodyFormat <> olFormatHTML Then
           aMail.Body = aMail.Body & vbCrLf & _
           "The file(s) were saved to " & sDeletedFiles
       Else
           aMail.HTMLBody = aMail.HTMLBody & "<p>" & _
           "The file(s) were saved to " & sDeletedFiles & "</p>"
       End If
       
       aMail.Save
       'sets the attachment path to nothing before it moves on to the next message.
       sDeletedFiles = ""
    
       End If
    Next 'end aMail
     
ExitSub:
 
Set oAttachments = Nothing
Set aMail = Nothing
Set oSelection = Nothing
Set objApp = Nothing
End Sub

步驟 6:按下F5鍵運行此VBA代碼。

現在,所選郵件中的所有附件都已刪除,並且在所有所選郵件的底部留下了指向每個已刪除附件的超鏈接。

doc-delete-attachments-7


使用Kutools for Outlook輕鬆刪除一封或多封郵件中的所有附件

Kutools for Outlook的「拆解所有附件」工具可以快速從Outlook中的一封或多封所選郵件中刪除所有附件。請按照以下步驟操作。

Kutools for Outlook:擁有超過100個實用的Outlook插件, 可免費試用30天無任何限制

1. 選擇一或多封帶有您想要刪除附件的郵件,然後點擊 Kutools > 附件工具 > 拆解所有附件。請參見截圖:

doc-save-attachments-multiple-emails6

2. 在「拆離設定」對話框中,請進行以下配置。

  • 2.1 點擊「瀏覽」按鈕選擇一個文件夾來保存所有刪除的附件。
  • 2.2 默認情況下,「按以下樣式拆離附件」框已被勾選,請根據需要選擇一種方式將附件保存到不同文件夾中。
  • 2.3 點擊「確定」按鈕。請參見截圖:

doc-save-attachments-multiple-emails7

注意:
1. 如果您希望將所有附件保存到同一文件夾中,請取消勾選「創建子文件夾的方式」框。
2. 刪除附件後,郵件列表中的郵件附件圖標將消失。您可以勾選「拆離附件後,郵件依然保留附件圖標」選項來始終保留它。
2. 除了刪除所選郵件中的所有附件外,您還可以根據特定條件刪除附件。例如,您只想刪除大小超過500KB的附件,請點擊「高級選項」按鈕以展開條件,然後按照以下截圖所示進行配置。

doc-save-attachments-multiple-emails08

3. 在「拆解所有附件」對話框中點擊「」按鈕。

doc-save-attachments-multiple-emails9

4. 然後會彈出一個Kutools for Outlook對話框,告訴您刪除了多少附件。請點擊「確定」按鈕。

doc-save-attachments-multiple-emails10

現在,所有附件都立即被刪除,僅留下超鏈接在所選郵件中。您可以點擊超鏈接隨時打開相應的附件。

  如果您想免費試用此工具(30天),請點擊下載,然後按照上述步驟進行操作申請。