Note: The other languages of the website are Google-translated. Back to English
登入  \/ 
x
or
x
註冊  \/ 
x

or

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

一般來說,您可以通過單擊保存一封電子郵件的所有附件 附件 > 保存所有附件 在Outlook中。 但是,如果您需要保存所有收到的電子郵件和收到的電子郵件中的所有附件,那麼理想嗎? 本文將介紹兩種解決方案,可以將附件從Outlook自動下載到特定文件夾。


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

此方法將引入VBA腳本,並使用規則運行此腳本,以自動將Outlook附件下載並保存到特定文件夾。 請執行以下操作:

1。 按 其他 + F11 鍵以打開“ Microsoft Visual Basic應用程序”窗口。

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。 在“規則嚮導(您要檢查哪些條件?)”對話框中,請取消選中任何選項,然後單擊 下一頁 按鈕。 然後點擊 在彈出的Microsoft Outlook對話框中單擊按鈕。 看截圖:

8。 現在,在“規則嚮導”(您要對消息做什麼?)對話框中,請: (1) 造訪 運行腳本 選項; (2) 點擊文字 一個腳本 打開“選擇腳本”對話框,選擇我們在步驟2中添加的腳本,然後單擊 OK 按鈕; (3) 點擊 下一頁 按鈕。

9。 在“規則嚮導(是否有例外?)”對話框中,請單擊 下一頁 直接點擊。

10。 現在,在最後一個“規則嚮導”對話框中,請在 步驟 框,根據需要檢查選項 步驟 部分,然後單擊 按鈕。

11。 關閉“規則和警報”對話框。

現在,所有附件都將從您的電子郵件帳戶下載並保存到指定的目標文件夾中。 並且所有傳入電子郵件的附件也將自動下載並保存到指定的文件夾中。


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

如果您安裝了Kutools for Outlook,則可以應用它 自動分離 選項以自動下載所有Outlook附件並輕鬆保存到特定文件夾。

Kutools for Outlook:為Outlook添加了100多種方便的工具,可以在60天內免費試用,沒有任何限制。 閱讀更多      立即免費試用

1。 點擊 Kutools > 自動分離 > 啟用 啟用自動分離功能。

2。 繼續點擊 Kutools > 自動分離 > 自動分離管理器.

3。 在“自動分離附件”對話框中,檢查 自動分離所有收到的附件 選項,然後進行如下配置:
(1)點擊瀏覽按鈕  指定目標文件夾以保存自動分離的附件;
(2)可以選擇檢查 使用以下樣式創建子文件夾 選項,然後從下拉列表下面選擇一種子文件夾樣式;
(3)可以選擇檢查 只有帶有以下擴展名的附件 選項,然後在下面的框中鍵入附件文件擴展名;
(4)可以選擇檢查 附件圖標仍保留在電子郵件中 選項。

備註:如果需要自動分離發件人的附件,則可以檢查 按規則自動分離附件 選項,點擊 新產品 按鈕,然後在第二個“自動分離附件”對話框中鍵入發件人的電子郵件地址並指定目標文件夾。

4。 點擊 Ok 按鈕保存設置。

從現在開始,所有附件(或具有指定文件擴展名的附件,或根據您的設置來自指定發件人的附件)將自動保存。

備註:您可以將Kutools用於Outlook的 全部分離 (附件)功能或 保存全部 (附件)功能可在Outlook中快速從多封/所有收到的電子郵件中下載/保存所有附件。


演示:使用Kutools for Outlook自動將Outlook附件下載到文件夾


小技巧: : 在這個視頻裡, Kutools 選項卡添加者 Kutools for Outlook。 如果需要,請單擊 ,請點擊這裡。 免費試用60天!


相關文章:


Kutools for Outlook-為Outlook帶來100個高級功能,並使工作更加輕鬆!

  • 自動CC / BCC 根據規則發送電子郵件; 自動前進 自定義多封電子郵件; 自動回复 沒有交換服務器,還有更多自動功能...
  • BCC警告 -當您嘗試全部答复時顯示消息 如果您的郵件地址在“密件抄送”列表中; 缺少附件時提醒,還有更多提醒功能...
  • 在郵件對話中回复(全部)帶有所有附件; 回复許多電子郵件 片刻之間; 自動添加問候語 回复時將日期添加到主題中...
  • 附件工具:管理所有郵件中的所有附件, 自動分離, 全部壓縮,重命名全部,保存全部...快速報告, 計算選定的郵件...
  • 強大的垃圾郵件 習俗 刪除重複的郵件和聯繫人... 使您能夠在Outlook中做得更聰明,更快和更好。
拍攝kutools前景kutools選項卡1180x121
拍攝kutools前景kutools加標籤1180x121
 
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    JoaoAzevedo · 8 days ago
    Hi,
    The script works very well.
    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

    Everything works great but what if I have a number of attachments in the email and I only want to save the excel and pdf files which are attached and not all the files attached to the email?
    Does someone can help?
    Much appreciated.
    Joao
  • To post as a guest, your comment is unpublished.
    Hari · 3 months ago
    @Tom Hi Tom, I'm also facing the same problem..is that fixed for you??

  • To post as a guest, your comment is unpublished.
    GuestMas · 6 months ago
    @Brandie Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
    Dim oAttachment As Outlook.Attachment
    Dim sSaveFolder As String
    MsgBox "E:\Dropbox\Apps\Attachments" & F
    sSaveFolder = "E:\Dropbox\Apps\" & Format(Now(), "dd.mm_hh.mm.ss")
    For Each oAttachment In MItem.Attachments
    oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
    Next
    End Sub
  • To post as a guest, your comment is unpublished.
    filng · 10 months ago
    @Shilpa Hi Shilpa. At colabel we are developing a no-code solution that can automatically categorize and store your attachments into folders. We're currently looking for qualified beta users willing to test our solution for free. In case you think we might help you, just send me an email at filippo@colabel.com
  • To post as a guest, your comment is unpublished.
    Shilpa · 1 years ago
    @Brandie HI All, I did all the steps but my script is not working.
  • To post as a guest, your comment is unpublished.
    Brandie · 1 years ago
    I got the script to run, everything works, but is there anyway to prevent the original email from being deleted? It is going directly into my "permanently deleted" files. I'd like the emails to stay right where they are rather than being deleted.

  • To post as a guest, your comment is unpublished.
    nilima · 1 years ago
    @cheunt2@gmail.com thank you so much! This solved my problem. Script was not running at all!
  • To post as a guest, your comment is unpublished.
    TGG · 1 years ago
    @jahangir because of security rules thisis not standard active from outlook 2013 and later.

    For outlook 2016 you need to add this to the registry:

    HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security
    DWORD: EnableUnsafeClientMailRules
    Value: 1
  • To post as a guest, your comment is unpublished.
    jahangir · 1 years ago
    i am not find "run a script" option please?
  • To post as a guest, your comment is unpublished.
    kellytte · 1 years ago
    @Sipho Hi sipho,
    If you enable the Auto Save Attachments or Auto Detach Attachments feature of Kutools for Outlook, they will save or detach attachments automatically from new incoming emails only when Outlook is running,
  • To post as a guest, your comment is unpublished.
    Joon Lin Ng · 1 years ago
    @cheunt2@gmail.com Thank you very much..
  • To post as a guest, your comment is unpublished.
    Sipho · 1 years ago
    Hi,


    Does Kutools automatically save the emails even when outlook is not opened and if not how can I do this?


    Thanks
  • To post as a guest, your comment is unpublished.
    Aftab · 1 years ago
    @cuatro2006@gmail.com HI, I need the entire timestamp in the file name to be saved as i am recieving the attachment everyhour
  • To post as a guest, your comment is unpublished.
    kellytte · 1 years ago
    @Guil Hi Guil,
    If you use the Detach All (Attachments) of Kutools for Outlook, you can specify to place the attachments into subfolders which are named as message subject-receive time.
  • To post as a guest, your comment is unpublished.
    Guil · 1 years ago
    Hi,

    How can I save this with a timestamp in the file name? The files I receive via e-mail always have the same name and the newer file overrides the previous one.

    Thanks in advance.

    Guil
  • To post as a guest, your comment is unpublished.
    Frodo · 1 years ago
    @Suz I was having the same problem, and enabling all macros fixed it for me as well.
  • To post as a guest, your comment is unpublished.
    Roberta · 2 years ago
    @kellytte Hi,
    I have retored the Run a script option in Outlook. But it still doesen't work. the message error is "This rule is not available in the current mode". Can you help me please?
  • To post as a guest, your comment is unpublished.
    Anthony · 2 years ago
    Hello, this code is running but MItem.Attachments.Count shows 0. When i try in debug mode watch this variable it reread and value shows more than 1. Help please. Why the variable didn't read in automatic mode?
  • To post as a guest, your comment is unpublished.
    kellytte · 2 years ago
    @Krishnakant Hi Krishnakant,
    In this article, I have introduced the method to restore the Run a script option in Outlook. Hope it can help you.
    https://www.extendoffice.com/documents/outlook/4640-outlook-rule-run-a-script-missing.html
  • To post as a guest, your comment is unpublished.
    Krishnakant · 2 years ago
    Hello,

    Its not showing 'run a script' action. Can you help please?


    Thanks

    Krishnakant
  • To post as a guest, your comment is unpublished.
    Katagihallimath · 2 years ago
    Is this correct?

    Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
    Dim oAttachment As Outlook.Attachment
    Dim sSaveFolder As String
    sSaveFolder = "D:\Adarsh\My\Payslips\" & Year(Date)Format(Date, "DD") & Format(Date, "Mmm")
    For Each oAttachment In MItem.Attachments
    oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
    Next
    End Sub
  • To post as a guest, your comment is unpublished.
    Tom · 2 years ago
    My Computer will only download the attachments when I run the rule manually. it doesn't automatically download the attachments when new emails arrive. Is that how it is supposed to be or could I have something set up wrong?
  • To post as a guest, your comment is unpublished.
    Katagihallimath · 2 years ago
    Hello, I tried downloading the attachments to a folder but the code doesn't seem to work.

    Kindly Help.

    Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
    Dim oAttachment As Outlook.Attachment
    Dim sSaveFolder As String
    sSaveFolder = "D:\Adarsh\My\Payslips\" & Year(Date)Format(Date, "DD") & Format(Date, "Mmm")
    For Each oAttachment In MItem.Attachments
    oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
    Next
    End Sub
  • To post as a guest, your comment is unpublished.
    Namig Heydarov · 2 years ago
    Hi all,
    I've running a command, but after restart of Outlook it stops. Do you have any idea how to solve it?
    Thanks!
  • To post as a guest, your comment is unpublished.
    James · 2 years ago
    Hi. Is it possible to save just the pdf files from the outlook attachment?
  • To post as a guest, your comment is unpublished.
    cuatro2006@gmail.com · 2 years ago
    @Scott Hi, try whith this

    Path = "\\myfolder\folder1\"
    nombre = "filename"
    fecha = Year(Date) & Format(Month(Date), "00") & Format(Day(Date) , "00")
    olItem.Attachments(1).SaveAsFile Path & nombre & fecha & ".txt"
  • To post as a guest, your comment is unpublished.
    cuatro2006@gmail.com · 2 years ago
    @Alex Hi, show me the script, maybe I can help you
  • To post as a guest, your comment is unpublished.
    Alex · 2 years ago
    I wrote the script but no files are saving to my folder. Any suggestions?
  • To post as a guest, your comment is unpublished.
    Scott · 2 years ago
    Is there a way to modify the file name to include the date (ie: Filename.Date.filetype)
  • To post as a guest, your comment is unpublished.
    cuatro2006@gmail.com · 2 years ago
    Hello!
    I need that if the attachment is empty, that the macro left does not perform any action
  • To post as a guest, your comment is unpublished.
    Martin · 2 years ago
    In option 1, where am I supposed to hit ALT + F11? I tried with Outlook opened and it isn't working. Normal ALT + F11 does nothing, and ALT Gr + F11 opens my Intel HD Graphic Control Panel.
  • To post as a guest, your comment is unpublished.
    Rob · 2 years ago
    Has anyone been able to figure out a way for this to work if the files you are saving all have the same name?


    I get a bunch of files that I need to save daily, but there are at least 2 of each with the same name.


    If anyone has any suggestions that would be greatly appreciated!!
  • To post as a guest, your comment is unpublished.
    Jasmin Nolasco · 2 years ago
    @Alfredo Funes https://www.extendoffice.com/documents/outlook/4640-outlook-rule-run-a-script-missing.html
  • To post as a guest, your comment is unpublished.
    Almira · 3 years ago
    Can I save attachments from 1 category in my email box? I don't need all of them, so I need select it. I have trial version of Kutools and in Options I have just 3 tabs: General, Detach&save and Compress. I saw on the page, that you have tab Filter. So Can I select and make settings from which category to save attachments?
  • To post as a guest, your comment is unpublished.
    Almira · 3 years ago
    @kelly.extendoffice@gmail.com Hi! Did you finish with this project? I mean do you have new version which can do 1) and 2) steps? I need save attachments from 1 category in email box, I don't need all of attachments.
  • To post as a guest, your comment is unpublished.
    Alfredo Funes · 3 years ago
    what if "Run a Script" is not available in "What do you want to do with the message" section?
  • To post as a guest, your comment is unpublished.
    Raynardo Pardo · 3 years ago
    Hello, Is there a VBA script for CSV attachment. I currently have report jobs that automatically goes into named folders in outlook I would now like for those files in the folders extract itself and go into the corresponding folders on my desktop. Hope this makes sense. Please Help! I am very new to VBA.
  • To post as a guest, your comment is unpublished.
    Dan · 3 years ago
    Hello, a few questions:

    1) This software not only saves the attachments but also the email message itself as a png file correct?
    2) This software will let us save each new email in a new subfolder if we set it up correct?
    3) This software will let us set up filters to control which emails get sent to dropbox and which ones are passed on correct?

    Thank You!
  • To post as a guest, your comment is unpublished.
    maxgiaco01@gmail.com · 3 years ago
    Hi, if you need to manage widely the attachments this solution is the best, but if you own a Dropbox account there are some email providers that automatically upload every attachment to Dropbox account. It means that you get the attachment in dropbox folder even if you hadn't read the email. I use servermx.com because they did a customization about the Dropbox path where I need to put the attachments.
  • To post as a guest, your comment is unpublished.
    faitharces29@gmail.com · 3 years ago
    Hi there,

    After having gone through all the steps it does work. The only thing is that while it saves the message as a png file, I would also like the script to actually go to the link in the message and download the data from there. Any good ideas how to extend the script?

    Thanks,

    Laszlo
  • To post as a guest, your comment is unpublished.
    Suz · 3 years ago
    @regis.saintgirons@gmail.com Hi, had a problem with it as well. For me, it were the Outlook settings under Trust Centre. All macros had been disabled. Once I enabled the macros to run on outlook, the script appeared to run and save the file.
  • To post as a guest, your comment is unpublished.
    kelly001 · 3 years ago
    @regis.saintgirons@gmail.com Hi Regis,
    It's hard to figure out the problem. What about trying Kutools for Outlook’s Automatically Detach feature? This feature only requires you to check one options, and all attachments will be automatically downloaded to the specified folder in futre!
  • To post as a guest, your comment is unpublished.
    regis.saintgirons@gmail.com · 3 years ago
    @regis.saintgirons@gmail.com I should add that I am using a gmail inbox
  • To post as a guest, your comment is unpublished.
    regis.saintgirons@gmail.com · 3 years ago
    I need help please !

    I have implemented the rule and the macro as explained. I have even added a msgbox line to make sure that all was ok and it is as the mail subject is properly displayed but the attachement is not saved

    Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
    Dim oAttachment As Outlook.Attachment
    Dim sSaveFolder As String
    MsgBox "Mail Subject: " & MItem.Subject
    sSaveFolder = "C:\Users\regis\Documents\Attach\"
    For Each oAttachment In MItem.Attachments
    oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
    Next
    End Sub


    What am I doing wrong?
  • To post as a guest, your comment is unpublished.
    kelly.extendoffice@gmail.com · 3 years ago
    @Lahiri Shuvo Hi Lahiri,
    Kutools for Outlook has released the Detach All feature, and you can easily save all attachments in the specified mail folder by the new Detach All feature.
  • To post as a guest, your comment is unpublished.
    kelly.extendoffice@gmail.com · 3 years ago
    @judith Hi Judith,
    Do you mean only save the attachments? Kutools for Outlook’s Detach All feature is designed to save all attachments from multiple emails.
  • To post as a guest, your comment is unpublished.
    kelly.extendoffice@gmail.com · 3 years ago
    @judith In the lastest version of Outlook, the "run a script" option is removed from the Outlook rules. You can follow the method in this article to restore it: https://www.extendoffice.com/documents/outlook/4640-outlook-rule-run-a-script-missing.html
  • To post as a guest, your comment is unpublished.
    Lahiri Shuvo · 3 years ago
    With the VBA script, it's running perfectly for the whole mailbox but I just need to save attachments form a specific folder. Can anyone help me ?
  • To post as a guest, your comment is unpublished.
    judith · 3 years ago
    guys i want to save only documents not the email
  • To post as a guest, your comment is unpublished.
    judith · 3 years ago
    i am failing to get "run the script" in the rules wizard.