我有以下工作代码从我自己的Outlook电子邮件帐户中提取附件,但我需要为另一个帐户设置,该帐户被设置为自动流程的默认回复电子邮箱。
我不完全确定如何告诉下面的代码检查该邮箱而不是我自己的邮箱。我尝试过设置Inbox变量的不同变体,但到目前为止它们都没有。这是在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
答案 0 :(得分:1)
试试这个:
Set Inbox = ns.Folders("MailboxName").Folders("Inbox")
答案 1 :(得分:0)
使用Namespace.GetSharedDefaultFolder
Set recip = ns.CreateRecipient("other mailbox owner")
recip.Resolve
Set Inbox = ns.GetSharedDefaultFolder(recip, olFolderInbox)