跳到主要內容

如何自動將附件從Outlook下載/保存到特定文件夾?

雖然在 Outlook 中保存單封電子郵件的所有附件非常簡單,但使用 附件 > 保存所有附件 選項,管理多封電子郵件中的附件(尤其是大量附件)可能更具挑戰性。本文介紹兩種有效的解決方案,用於自動將 Outlook 電子郵件中的附件下載到特定資料夾。這些方法在處理大量電子郵件和附件時特別有用,可以簡化流程並節省時間。


使用 VBA 和規則自動將 Outlook 附件下載到資料夾

此方法涉及使用 VBA 腳本,當使用特定規則執行時,該腳本將自動下載 Outlook 電子郵件中的附件並將其儲存到指定資料夾中。請繼續執行以下步驟:

  1. 媒體推薦 Alt + F11鍵 打開 Microsoft Visual Basic for Applications 窗口。
  2. 點擊 插入 > 模塊,然後將下面的VBA腳本貼到新開啟的 模塊 窗口。

    VBA:自動將Outlook附件保存到某個文件夾

    Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
    Dim oAttachment As Outlook.Attachment
    Dim sSaveFolder As String
    sSaveFolder = "C:\Users\DT168\Documents\outlook-attachments\"
    For Each oAttachment In MItem.Attachments
    oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
    Next
    End Sub

    注意: 請找到該線 sSaveFolder =“ C:\ Users \ DT168 \ Documents \ outlook-attachments \”,並將其替換為您所需的目標資料夾的路徑。

  3. 儲存 VBA 腳本並關閉 Microsoft Visual Basic for Applications 窗口。
  4. 轉到 郵件 查看,然後單擊 首頁 > 規則 > 管理規則和警報.
  5. 在開 規則和警報 對話框,請點擊 新規則 上的按鈕 電子郵件規則 標籤。
  6. 規則嚮導 出現對話框,請選擇 對我收到的消息應用規則 選項,然後單擊 下一頁 按鈕。
  7. 規則精靈(您要檢查哪些條件?) 對話框中,單擊 下一頁 按鈕而不選擇任何選項。然後單擊 彈出窗口中的按鈕 微軟Outlook 對話框。
  8. 在下面的 規則精靈(您想對訊息做什麼?) 對話框,進行以下操作:
    1. Check the 運行腳本 選項。 小提示: 如果您沒有看到該選項,請 請前往本教學課程,了解如何在 Outlook 中啟用「執行腳本」選項.
    2. 點擊藍色下劃線的“腳本”文字以打開 選擇腳本 對話框。在這裡,選擇您新增的腳本 步驟 2 並點擊 OK 按鈕。
    3. 點擊 下一頁 按鈕繼續。
  9. 規則嚮導(有例外嗎?) 對話框,請點擊 下一頁 直接點擊。
  10. 在最後 規則嚮導 對話方塊中,請命名規則 步驟 1 框,根據需要檢查選項 步驟 2 部分,然後單擊 按鈕。
  11. 關上 規則和警報 對話框。

結果

現在,如果您選擇「立即對收件匣中已有的郵件執行此規則」選項,則您電子郵件帳戶中的所有附件都將下載並儲存在指定的目標資料夾中。此外,如果您勾選「開啟此規則」選項,傳入電子郵件中的所有附件將自動下載並儲存到指定資料夾。


使用 Kutools for Outlook 自動將 Outlook 附件下載到資料夾

這款獨特的敏感免洗唇膜採用 Moisture WrapTM 技術和 Berry Mix ComplexTM 成分, Kutools for Outlook 安裝在您的電腦上,其 自動分離 功能可讓您根據您設定的條件自動下載所有或特定的 Outlook 附件,並方便地將它們導向至選定的資料夾。此外,此功能還提供了建立子資料夾的靈活性。它提供了兩種命名這些子資料夾的方法:您可以從其中一種格式中進行選擇,例如 [郵件資料夾]-[郵件主旨],或選擇將自訂文字字串作為後綴附加到您選擇的格式。此功能極大地改進了附件的組織和可訪問性。

Kutools for Outlook:透過 100 多種必備工具增強 Outlook 功能。 60 天免費試駕,無任何附加條件!   閱讀更多...   現在就下載!

  1. 點擊 庫工具 > 自動分離 開啟功能對話框。
  2. 自動分離附件 對話框中選擇 自動分離所有收到的附件 選項,並配置如下:
    1. 點擊瀏覽按鈕 指定儲存自動分離的附件的目標資料夾。
    2. (可選)檢查 依以下樣式分離附件 如果您希望建立子資料夾來儲存附件,請選擇此選項。
      • 以以下樣式創建子文件夾:以預定義格式之一命名子資料夾,例如 [郵件資料夾]-[郵件主旨].
      • 重命名以下樣式的已保存附件:使用預定義格式之一命名子資料夾,並添加自訂文字字串作為後綴。
    3. (可選)檢查 附件圖標仍保留在電子郵件中 在帶有附件的電子郵件中保留視覺指示器的選項。
    4. 點擊 確定。

結果

從現在開始,所有附件將在收到電子郵件後自動儲存到指定資料夾中。

小提示: 如果您想根據特定規則設定自動分離附件,請啟用 按規則自動分離附件 在選項 自動分離附件 對話。之後,點擊 全新 按鈕來定義您的篩選條件和所需的儲存設定。

筆記:

  • 想要訪問 自動分離 特徵? 下載 Kutools for Outlook 現在! 除此之外,Kutools 還擁有 100 多個其他功能,並提供 60 天免費試用。 不要等待,今天就來試試吧!
  • 如果您想從 Outlook 中的多封/所有收到的電子郵件中分離或下載現有附件,請套用 Kutools for Outlook 分離所有(附件) or 全部儲存(附件) 功能。

相關文章:


最佳辦公生產力工具

Kutools for Outlook - 超過 100 種強大的功能可增強您的 Outlook

🤖 人工智慧郵件助手: 具備人工智慧魔力的即時專業電子郵件——一鍵天才回覆、完美語調、多語言掌握。輕鬆改變電子郵件! ……

📧 電子郵件自動化: 外出(適用於 POP 和 IMAP)  /  安排發送電子郵件  /  發送電子郵件時按規則自動抄送/密件副本  /  自動轉送(進階規則)   /  自動添加問候語   /  自動將多收件者電子郵件拆分為單獨的訊息 ...

📨 電子郵件管理: 輕鬆回憶電子郵件  /  按主題和其他人阻止詐騙電子郵件  /  刪除重複的電子郵件  /  進階搜索  /  合併資料夾 ...

📁 附件專業版批量保存  /  批量分離  /  批量壓縮  /  自動保存   /  自動分離  /  自動壓縮 ...

🌟 介面魔法: 😊更多又漂亮又酷的表情符號   /  使用選項卡式視圖提高 Outlook 工作效率  /  最小化 Outlook 而不是關閉 ...

👍 一鍵奇蹟: 使用傳入附件回覆全部  /   反網路釣魚電子郵件  /  🕘顯示寄件者的時區 ...

👩🏼‍🤝‍👩🏻 通訊錄和行事曆: 從選定的電子郵件中大量新增聯絡人  /  將聯絡人群組拆分為各組  /  刪除生日提醒 ...

超過 100特點 等待您的探索! 按此處了解更多。

閱讀更多       免費下載      購買
 

 

Comments (115)
Rated 4.5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Thank you for this information
This comment was minimized by the moderator on the site
May i ask some question?

I usually received mail to many people and many kinds of files.
So i should distinguish each file.
But now, It can`t.

So Did you have any idea for this?
(like chacnged file name or and so on...)

Thank you for your help

BR
Hansu
This comment was minimized by the moderator on the site
Thank you for your great code
This comment was minimized by the moderator on the site
Hi,
I create Module in Microsoft VBA & save it
However when go to create Rules in Outlook, I can't see the select box of "Run a script"
What is the reason & how to fix it?
Thank you
This comment was minimized by the moderator on the site
Hi there,

In some versions of Outlook, especially in more recent updates, the "Run a Script" option might be disabled by default due to security concerns. To enable the "Run a Script" option in Outlook, you usually need to modify the registry settings. Here's a general guide on how to do it:

1. Close Outlook: Make sure Outlook is not running.
2. Open Registry Editor: Press Win + R, type regedit, and hit Enter.
3. Navigate to the Outlook Security Settings: Depending on your version of Outlook, you'll need to navigate to a specific path in the Registry Editor. For example, for Outlook 2016, 2019, and Microsoft 365, you might navigate to HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security.
4. Modify/Add the Registry Value:
4.1 Right-click in the right pane and choose New > DWORD (32-bit) Value.
4.2 Name the new value as EnableUnsafeClientMailRules.
4.3 Set its value to 1.
5. Close Registry Editor and restart your computer.
6. Open Outlook and check if the "Run a Script" option is available.
This comment was minimized by the moderator on the site
Ale kupa, oszuści. Maile zaczynają znikać. Nie mam moich wiadomości.
This comment was minimized by the moderator on the site
Hi, code works great however I am saving excel files and was wondering how I can modify the saved name. I recieve files like this "exa 2022-08.xlsx" how can I save the excel file as just "2022-08"?

this is my current code and my file saves however as just a file type not excel.

Public Sub PortlandDaily(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "T:\_Portland\Engineering Data\Daily Production Data\Test\"
For Each oAttachment In MItem.Attachments

Dim SplitName() As String
SplitName = Split(oAttachment.DisplayName, ".")

Dim RightName As String
RightName = Right(SplitName(0), 7)

Dim SaveName As String

SaveName = sSaveFolder & RightName

oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName

Next
End Sub
Rated 4.5 out of 5
This comment was minimized by the moderator on the site
Hi there,

Please try the code below:
Public Sub PortlandDaily(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "T:\_Portland\Engineering Data\Daily Production Data\Test\"
For Each oAttachment In MItem.Attachments
  Dim SplitName() As String
  SplitName = Split(oAttachment.DisplayName, ".")
  Dim RightName As String
  RightName = Right(SplitName(0), 7) 'You can also declare the file name here, e.g., RightName = "2022-08"
  Dim SaveName As String
  SaveName = sSaveFolder & RightName & "." & SplitName(1)
  oAttachment.SaveAsFile SaveName
Next
End Sub


Amanda
This comment was minimized by the moderator on the site
Hi. is it possible to give the attachment file an entirely new name, using information form the mail (for example the date of delivery).
This comment was minimized by the moderator on the site
Hi,
How can I create a VBA to save attachment (Excel file) in my location drive when email received in my outlook folder and using the file name based on cell value...Many thanks

Regards,
Anthony On
This comment was minimized by the moderator on the site
Bonjour, j'ai réussi à rajouter "exécuter un script" dans les règles et faire fonctionner le script dans outlook. Les pièces jointes d'un mail bien précis s'enregistrent parfaitement dans le dossier demandé. Sauf que j'aimerais enregistrer uniquement les fichiers .txt, et non les .pdf qui s'incrémentent également. Aussi j'ai une autre requête s'il vous plaît, le script fonctionne très bien pour définir un dossier de destination, mais je souhaite définir d'autres règles qui me permettraient d'enregistrer les pièces jointes d'autres mails vers un autre dossier de destination. J'ai essayé de faire un 2e module VBA, cela ne fonctionne pas. J'ai généré un deuxième projet VBA mais Outlook n'en gère qu'un seul. Dans ce cas, comment remédier s'il vous plait ? Merci pour ce tuto très clair pour moi qui suis débutante.
This comment was minimized by the moderator on the site
Hi pearl,
Could you please send the code you generated so that we can fix it?
Amanda
This comment was minimized by the moderator on the site
Hi Can we  download the attachment contains specific letters using VBA code
This comment was minimized by the moderator on the site
Hi DAS,
When you said “the attachment contains specific letters”, did you mean you want to download the attachments from specific letters?
Amanda
This comment was minimized by the moderator on the site
Hi,
I executed the VBA + Rule option and it seemed to work perfectly. However, it recently stopped working with no errors. The rule is set to read the subject line, move to a certain folder if there is a certain subject, and then run the script. I know the trigger is working in the rule because the first action (move to folder) is working as it should.
Any idea why the rule trigger would work, but the documents are no longer being saved?
Things I have tried/checked:-The file path is correct-I added delays in various spots in the vba using application.wait-outlook has been shutdown and re-opened, and so has my laptop
(disclosure: I am a bit of a VBA newbie, but have beginner level coding knowledge)
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