0

我在互联网上找到了这段代码,您可以在其中自动将附件保存在某个文件夹中:

   Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:\Temp"
    For Each objAtt In itm.Attachments
        objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
        Set objAtt = Nothing
    Next
End Sub

有什么办法可以将附件保存在不同的文件夹中?

谢谢

4

1 回答 1

2

您的示例代码对saveAttachtoDisk子目录中的目标文件夹进行硬编码。您可以通过参数将此信息传递到此子(的变体):

Public Sub saveAttachtoDisk(itm As Outlook.MailItem, saveFolder As String)
  Dim objAtt As Outlook.Attachment
  For Each objAtt In itm.Attachments
      objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
      Set objAtt = Nothing
  Next
End Sub

并这样称呼它:

Dim saveFolder As String
saveFolder = "C:\Some\Where\Else"
saveAttachtoDisk itm, saveFolder
...
saveAttachtoDisk otheritm, "d:\why\not\here"

当然,现在的问题是:这些“其他文件夹”应该如何确定?通过用户交互?通过应用于某些 Outlook/User/Main/System 属性的功能?

于 2013-01-11T13:59:31.260 回答