【发布时间】:2020-06-28 15:06:42
【问题描述】:
我有一个简短的 Outlook VBA 宏,可以将特定电子邮件中的附件下载到特定文件夹。
我的设置如下:
Apply this rule after the message arrives
From ******@***.com
And on this computer only
Move it to the pricing folder
And run Project1.saveAttachtoDrive
对于前景规则。
宏设置:图片默认,宏设置“启用所有宏”。
代码:
Public Sub saveAttachtoDrive(itm As Outlook.MailItem)
'Created by Selkie in order to automatically download attachments
Dim objAtt As Outlook.Attachment
'Shortening things
Dim dt As Date
'The date
Dim saveFolder As String
'We need to save the file somewhere
dt = Format(Date, "MMDDYY")
'Gotta get the date, and need it in a useable format
saveFolder = "L:\*******\Testing Folder\"
'Save location - change as needed
For Each objAtt In itm.Attachments
'For every attachment we get
objAtt.SaveAsFile saveFolder & dt & objAtt.DisplayName
'Save it
Set objAtt = Nothing
Next
End Sub
现在,当我运行非常相似的东西时,但作为文件夹抓取而不是在收到电子邮件时触发时,我确实设法下载了给定文件中的附件。
我做错了什么吗?我需要启用一些 Outlook 设置吗?还是我完全破坏了代码? (看起来和我在 3-4 个不同位置看到的东西非常相似,只是位置、cmets 和添加的日期都是独一无二的”
【问题讨论】:
-
运行时实际发生了什么?你没有描述出了什么问题,除了你的帖子标题。
-
绝对没有。电子邮件进来了,但附件不会保存。所以我想这是出乎意料的行为