メインコンテンツへスキップ

Outlookで電子メールからすべての添付ファイルを削除するにはどうすればよいですか?

通常、メールをプレビューするときは、右クリックして添付ファイルを削除し、 添付ファイルを削除する 項目。 電子メールメッセージに多くの添付ファイルが含まれている場合があり、それらをXNUMXつずつ削除するのは面倒です。 ここでは、XNUMXつの電子メール内のすべての添付ファイルを削除し、Outlookでも複数の電子メールからすべての添付ファイルを削除するXNUMXつの簡単なトリックを用意しています。

OutlookでXNUMXつの電子メールメッセージのすべての添付ファイルを手動で削除する
VBAコードを使用してOutlookの複数の電子メールメッセージからすべての添付ファイルを削除します
Kutools for Outlookを使用すると、XNUMXつまたは複数の電子メールからすべての添付ファイルを簡単に削除できます


OutlookでXNUMXつの電子メールメッセージのすべての添付ファイルを手動で削除する

選択した電子メールメッセージのすべての添付ファイルを簡単に削除できます。 添付ファイルを削除する Outlookの機能。

手順1:後で添付ファイルを削除する電子メールメッセージを選択します。

手順2:閲覧ウィンドウで添付ファイルのXNUMXつをクリックして、添付ファイルツールをアクティブにします。

ステップ3: すべてを選択します。 ボタンの 選択 グループを 添付ファイル タブには何も表示されないことに注意してください。

この手順により、この選択した電子メールメッセージのすべての添付ファイルを一度に選択できるようになります。

ステップ4: 添付ファイルを削除する ボタンの グループを 添付ファイル タブには何も表示されないことに注意してください。

手順5:警告ダイアログボックスで、 添付ファイルを削除する

次に、この選択した電子メールメッセージのすべての添付ファイルができるだけ早く削除されます。

Note:添付ファイルの削除機能は、Outlook 2010以降のバージョンでは正常に機能しますが、Outlook2007では機能しません。


Outlookで選択した複数の電子メールからすべての添付ファイルを簡単に削除できます。

すべての添付ファイルを切り離します の有用性 Kutools for Excel、以下のデモに示すように、選択した複数の電子メールからすべての添付ファイルを簡単に削除できます。 (添付ファイルは指定したフォルダに保存されます) 今すぐダウンロードして試してください! (30日間の無料トレイル)


VBAコードを使用してOutlookの複数の電子メールメッセージからすべての添付ファイルを削除します

Microsoft Outlookの複数の電子メールメッセージからすべての添付ファイルを削除する場合は、次の方法で簡単に削除できます。 私たちはあなたをお勧めします MicrosoftOutlookですべてのマクロを有効にする 最初に。

ステップ1:のフォルダに移動します マイドキュメント、新しいフォルダを作成し、名前を付けます OLA添付ファイル

ステップ2:添付ファイルを後で削除する複数の電子メールメッセージを選択します。

注: を押し続けると、連続しないメールメッセージを選択できます Ctrlキー キーを押してクリックします。

を押したまま、連続したメールメッセージを選択できます シフト キーを押してクリックします。

ステップ3:を押してVBAエディターを開きます 他の キーと F11 同時にキーを押します。

ステップ4:展開する Project1 > MicrosoftOutlookオブジェクト 左側のバーで、をダブルクリックします このOutlookSession エディターで開きます。 次のスクリーンショットを参照してください。

手順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コードを実行します。

これで、選択したすべての電子メールメッセージのすべての添付ファイルが削除され、選択したすべての電子メールメッセージの下部に削除された各添付ファイルへのハイパーリンクが残ります。


Kutools for Outlookを使用すると、XNUMXつまたは複数の電子メールからすべての添付ファイルを簡単に削除できます

  すべてを切り離す の添付ファイルユーティリティ Outlook用Kutools Outlookで選択したXNUMXつまたは複数の電子メールからすべての添付ファイルをすばやく削除できます。 次のようにしてください。

Outlook用Kutools :100を超える便利なOutlookアドインを使用して、 60日以内に制限なしで無料でお試しいただけます.

1.削除する添付ファイルを含むXNUMXつまたは複数の電子メールメッセージを選択し、[ クツール > アタッチメントツールすべてを切り離す。 スクリーンショットを参照してください:

2。 の中に デタッチ設定 ダイアログボックスで、次のように構成してください。

  • 2.1 ブラウズ ボタンをクリックして、削除されたすべての添付ファイルを保存するフォルダを選択します。
  • 2.2デフォルトでは、 以下のスタイルでアタッチメントを取り外します チェックボックスがオンになっている場合は、必要に応じて電子メールに基づいて添付ファイルを別のフォルダに保存するオプションを選択してください。
  • 2.3 OK ボタン。 スクリーンショットを参照してください:

ノート:
1.すべての添付ファイルを同じフォルダに保存する場合は、チェックを外してください 次のスタイルでサブフォルダーを作成します ボックス。
2.添付ファイルを削除すると、メーリングリストの電子メールから添付ファイルアイコンが消えます。 あなたはチェックすることができます 添付ファイルアイコンはまだメールに残っています 常にそれを保つための箱。
2.選択した電子メールからすべての添付ファイルを削除する以外に、特定の条件でのみ添付ファイルを削除できます。 たとえば、サイズが500KBを超える添付ファイルのみを削除する場合は、[ 詳細オプション ボタンをクリックして条件を展開し、次に示すように構成します。

3。 クリック 有り ボタンの すべてを切り離す ダイアログボックス。

4.次に、 Outlook用Kutools 削除された添付ファイルの数を示すダイアログボックスがポップアップ表示されます。 クリックしてください OK  

これで、すべての添付ファイルがすぐに削除され、選択した電子メールにハイパーリンクのみが残ります。 必要に応じて、ハイパーリンクをクリックして、対応する添付ファイルを開くことができます。

  このユーティリティの無料トライアル(60日)が必要な場合は、 クリックしてダウンロードしてください、次に、上記の手順に従って操作を適用します。


最高のオフィス生産性向上ツール

Outlook用Kutools - Outlook を強化する 100 以上の強力な機能

🤖 AIメールアシスタント: AI の魔法を備えたインスタント プロのメール - ワンクリックで天才的な返信、完璧な口調、多言語の習得。メールを簡単に変革しましょう! ...

📧 自動メール: 不在時 (POP および IMAP で利用可能)  /  メール送信のスケジュール設定  /  メール送信時のルールによる自動CC/BCC  /  自動転送 (高度なルール)   /  あいさつを自動追加   /  複数受信者の電子メールを個別のメッセージに自動的に分割する ...

📨 電子メール管理: メールを簡単に思い出す  /  件名などで詐欺メールをブロック  /  重複するメールを削除する  /  高度な検索  /  フォルダーを統合する ...

📁 アタッチメント プロバッチ保存  /  バッチデタッチ  /  バッチ圧縮  /  自動保存   /  自動デタッチ  /  自動圧縮 ...

🌟 インターフェースマジック: 😊もっと可愛くてクールな絵文字   /  タブ付きビューで Outlook の生産性を向上  /  Outlook を閉じる代わりに最小化する ...

???? ワンクリックの驚異: 受信した添付ファイルをすべてに返信する  /   フィッシングメール対策  /  🕘送信者のタイムゾーンを表示 ...

👩🏼‍🤝‍👩🏻 連絡先とカレンダー: 選択したメールから連絡先を一括追加  /  連絡先グループを個別のグループに分割する  /  誕生日のリマインダーを削除する ...

オーバー 100の特長 あなたの探索をお待ちしています! ここをクリックして詳細をご覧ください。

 

 

Comments (33)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello,
MS recently changed the storage limits for Hotmail. Attachments are counted towards storage used.
Many users would like to remove only the attachments in bulk. Your VBA script may be the solution for these users.
Can you confirm if this script still works for Hotmail users in 2023?
Thank you in advance.
This comment was minimized by the moderator on the site
The article and the comments below are very helpful! Thanks!
This comment was minimized by the moderator on the site
 Hello, I use the VBA code, unfortunaltely all the attachements were deleted from the emails, and they were not storage in any of the folders... so i lost many attachment files. anyone knows how can i restored
This comment was minimized by the moderator on the site
The VBA code shown in solution 2 works fine, however, but my goal is to remove only attachments which are not inline the message. Being VBA ignorant I would like to ask if it is possible to modify the code in that manner it would remove only attached files, not pictures inside the email text. It would surely make my day :)

Thank you in advance
This comment was minimized by the moderator on the site
Can somebody change the code so that only for example attachments named "TermsAndConditions.pdf" are deleted
This comment was minimized by the moderator on the site
Dear Rene,
Please follow the steps in the above second method, run the below VBA code. In an opening dialog box, please enter the attachment's name with the file extension (such as test.docx), and then click the OK button to just remove it from the selected email.

Sub ReplaceAttachmentsToLink()
Dim xMail As Outlook.MailItem
Dim xAttachments As Outlook.Attachments
Dim xSelection As Outlook.Selection
Dim i, xCount As Long
Dim xFile, xFldPath, xDelFiles, xFileName As String
Dim xFlag As Boolean

xFldPath = CreateObject("shell.Application").NameSpace(5).self.Path
On Error Resume Next
Set xSelection = Outlook.ActiveExplorer.Selection
xFldPath = xFldPath & "\OLAttachments"
xFlag = False
xFileName = InputBox("Attachment name:", "Kutools for Outlook")

If StrPtr(xFileName) = 0 Then Exit Sub
If xFileName <> "" Then
For Each xMail In xSelection
Set xAttachments = xMail.Attachments
xCount = xAttachments.Count
If xCount > 0 Then
For i = xCount To 1 Step -1
xFile = xAttachments.Item(i).FileName
If xFileName = xFile Then
xFlag = True
xFile = xFldPath & "\" & xFile
xAttachments.Item(i).SaveAsFile xFile
xAttachments.Item(i).Delete
If xMail.BodyFormat <> olFormatHTML Then
xDelFiles = xDelFiles & vbCrLf & ""
Else
xDelFiles = xDelFiles & "
" & "" & xFile & ""
End If
End If
Next i
If xFlag = True Then
If xMail.BodyFormat <> olFormatHTML Then
xMail.Body = xMail.Body & vbCrLf & "The file(s) were saved to " & xDelFiles
Else
xMail.HTMLBody = xMail.HTMLBody & "
" & "The file(s) were saved to " & xDelFiles & "
"
End If
End If
xMail.Save
xDelFiles = ""
End If
Next
If xFlag = False Then
MsgBox "The Attachment does not exist!"
Else
MsgBox "The attachment has been deleted."
End If
Else
MsgBox "Please input a attachment name"
End If
Set xAttachments = Nothing
Set xMail = Nothing
Set xSelection = Nothing
End Sub
This comment was minimized by the moderator on the site
Method 1 doesn't work here, as there's only 1 option under 'Selection': Copy.
This comment was minimized by the moderator on the site
Dear Peter,
Outlook users are reporting that the Select All (attachments) feature in Outlook 2016 is missing.
This comment was minimized by the moderator on the site
The VBA Code solution was great .... worked beautifully
This comment was minimized by the moderator on the site
Compile Error Sub or Function not defined??
This comment was minimized by the moderator on the site
VBA code worked great. Many thanks!
This comment was minimized by the moderator on the site
Hi This was really helpful , but as all attachments were not saved when i tried again it gives a message "the macros in this project are disabled".....tried enabling macros in outlook but no luck, any one can help! Regards Lisa
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations