- 首先确认outlook 2016 user权限
- 右击outlook,选属性,查看owener是当前用户,还是另有admin用户,需要owener账户进行设置。
- 打开Outlook - Option - Trust Center - Truster Center Settings - Macro Settings - 勾选Enable all macros。 然后继续在Truster Center Settings - Email Security - 勾选Allow script in shared folders 和 All script in public folders
- 重启Outlook
- 使outlook 2016有“run a script”选项
- 点击键盘“win键+R”,输入“regedit”;
- 进入“Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security
- 点击空白处,new->DWORD(32-bit) Value,重命名为“EnableUnsafeClientMailRules”,双击该文件,Value data改为“1”
-
重启Outlook
image.png
- 在outlook邮箱插入VBA脚本
点击“Alt + F11”,双击界面编辑框,插入如下代码
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Public Sub SaveAttach(MyItem As Outlook.MailItem)
SaveAttachment MyItem, "C:\Data\MailAttached\"
'MsgBox "附件已保存"
End Sub
Private Sub SaveAttachment(ByVal Item As Outlook.MailItem, path, Optional condition = "*")
Dim olAtt As Outlook.Attachment
Dim i As Integer
If Item.Attachments.Count > 0 Then
For i = 1 To Item.Attachments.Count
Set olAtt = Item.Attachments(i)
If olAtt.FileName Like condition Then
olAtt.SaveAsFile path & olAtt.FileName
End If
Next
End If
Set olAtt = Nothing
Sleep 100
End Sub
Private Sub UserForm_Click()
End Sub
-
创建下载的规则
注意点击“run a script”,选择刚才的脚本
image.png
- 如果发现有诡异的问题,重启下outlook
参考:https://www.jianshu.com/p/7c3cc7231735
网友评论