【发布时间】:2020-06-30 08:05:01
【问题描述】:
我有下面的工作代码来从我自己的 Outlook 电子邮件帐户中提取附件,但是我需要为另一个帐户执行此操作,该帐户设置为自动流程的默认回复电子邮件框。
我不完全确定如何告诉下面的代码检查那个邮箱而不是我自己的。我尝试了设置收件箱变量的不同变体,但到目前为止,它们都没有奏效。这是在 Access 2013 中完成的。
Private Sub GetAttachments()
Dim ns As Namespace
Dim Inbox As Outlook.MAPIFolder
Dim Item As Object
Dim Atmt As Outlook.Attachment
Dim FileName As String
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
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
If Atmt.Type = 1 And InStr(Atmt, "xlsx") > 0 Then
FileName = "C:\attachments\" & Atmt.FileName
Atmt.SaveAsFile FileName
End If
Next Atmt
Next Item
End Sub
【问题讨论】: