让Outlook自动保存邮件中附件

1. 在VBA中编写模块代码,实现保存附件的功能

在Outlook中按Alt + F11调出VBA编辑器,贴入以下代码

Public Sub SaveAttach(Item As Outlook.MailItem)
    'Declare variables
    Dim folderPath As String
    folderPath = "E:\attachments\"
    Dim condition As String
    condition = "*"

    Dim olAtt As Attachment
    Dim i As Integer

    'Go through each attachments
    If Item.Attachments.Count > 0 Then
        For i = 1 To Item.Attachments.Count
            Set olAtt = Item.Attachments(i)
           
            'Save the attachment if it matches the condition
            If olAtt.FileName Like condition Then
                olAtt.SaveAsFile folderPath & DateTime.Timer & "_" & olAtt.FileName
            End If
        Next
    End If
   
    Set olAtt = Nothing
End Sub

2. 新建规则,邮件接收后运行脚本

新建规则,第二步中勾选运行脚本,选择我们新建的脚本SaveAttach

3. 修改安全设置,允许脚本运行

重启Outlook使设置生效。

转载于:https://www.cnblogs.com/fengjunkuan/p/4026245.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值