跳到主要内容

如何自动将附件从Outlook下载/保存到特定文件夹?

虽然在 Outlook 中保存单封电子邮件的所有附件非常简单,但使用 附件 > 保存所有附件 选项,管理多封电子邮件中的附件(尤其是大量附件)可能更具挑战性。本文介绍两种有效的解决方案,用于自动将 Outlook 电子邮件中的附件下载到特定文件夹。这些方法在处理大量电子邮件和附件时特别有用,可以简化流程并节省时间。


使用 VBA 和规则自动将 Outlook 附件下载到文件夹

此方法涉及使用 VBA 脚本,当使用特定规则执行该脚本时,该脚本将自动下载 Outlook 电子邮件中的附件并将其保存到指定文件夹中。请继续执行以下步骤:

  1. 媒体 Alt + 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应用程序 窗口。
  4. 邮箱: 查看,然后单击 主页 > 规则 > 管理规则和警报.
  5. 在开幕 规则和警报 对话框,请点击 新规则 上的按钮 电子邮件规则 标签。
  6. 规则向导 出现对话框,请选择 对我收到的消息应用规则 选项,然后单击 下一页 按钮。
  7. 规则向导(您要检查哪些条件?) 对话框中,单击 下一页 按钮而不选择任何选项。然后单击 USB MIDI(XNUMX通道) 弹出窗口中的按钮 微软Outlook 对话框。
  8. 在下面的 规则向导(您想对消息做什么?) 对话框,进行如下操作:
    1. 访问 运行脚本 选项。 提示: 如果您没有看到该选项,请 转至本教程,了解如何在 Outlook 中启用“运行脚本”选项.
    2. 单击蓝色下划线的“脚本”文本以打开 选择脚本 对话框。在这里,选择您添加的脚本 并单击 OK 按钮。
    3. 点击 下一页 按钮继续。
  9. 规则向导(有例外吗?) 对话框,请点击 下一页 直接点击。
  10. 在最后 规则向导 对话框中,请命名规则 框,根据需要检查选项 部分,然后单击 完成 按钮。
  11. 关上 规则和警报 对话框。

结果

现在,如果您选择“立即对收件箱中已有的邮件运行此规则”选项,则您电子邮件帐户中的所有附件都将被下载并存储在指定的目标文件夹中。此外,如果您选中“打开此规则”选项,传入电子邮件中的所有附件将自动下载并保存到指定文件夹中。


使用 Kutools for Outlook 自动将 Outlook 附件下载到文件夹

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