【发布时间】:2011-03-16 22:34:19
【问题描述】:
我在 Outlook 中创建了一个名为“报告”的文件夹。此文件夹包含在每封电子邮件中带有一个附件的电子邮件。我想使用 ACCESS VBA 将 Outlook 中“报告”文件夹中的附件保存到我计算机的本地驱动器中。这是我到目前为止的代码,但给了我错误。请帮忙:
Sub GetAttachments()
Dim ns As NameSpace
Dim Inbox As Outlook.MAPIFolder
Dim folder As Outlook.MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set ns = GetNamespace("MAPI")
Set Inbox = ns.Folders.Item("Reports") // I get an error in this line says an object could not be found
i = 0
If Inbox.Items.Count = 0 Then
MsgBox "There are no messages in the Inbox.", vbInformation, _
"Nothing Found"
Exit Sub
End If
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
FileName = "C:\Automation\" & Atmt.FileName
Atmt.SaveAsFile FileName // here is another error says method is not found
i = i + 1
Next Atmt
Next Item
【问题讨论】: