使用 Microsoft Access,需要从不同帐户的 Outlook 电子邮件中提取附件
Using Microsoft Access, need to pull attachments from Outlook emails of a different account
我有下面的工作代码可以从我自己的 Outlook 电子邮件帐户中提取附件,但是我需要为另一个帐户执行此操作,该帐户设置为自动流程的默认回复邮箱。
我不完全确定如何让下面的代码检查那个邮箱而不是我自己的邮箱。我已经尝试了设置收件箱变量的不同变体,但到目前为止,其中 none 已经奏效了。这是在 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
试试这个:
Set Inbox = ns.Folders("MailboxName").Folders("Inbox")
使用Namespace.GetSharedDefaultFolder
Set recip = ns.CreateRecipient("other mailbox owner")
recip.Resolve
Set Inbox = ns.GetSharedDefaultFolder(recip, olFolderInbox)
我有下面的工作代码可以从我自己的 Outlook 电子邮件帐户中提取附件,但是我需要为另一个帐户执行此操作,该帐户设置为自动流程的默认回复邮箱。
我不完全确定如何让下面的代码检查那个邮箱而不是我自己的邮箱。我已经尝试了设置收件箱变量的不同变体,但到目前为止,其中 none 已经奏效了。这是在 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
试试这个:
Set Inbox = ns.Folders("MailboxName").Folders("Inbox")
使用Namespace.GetSharedDefaultFolder
Set recip = ns.CreateRecipient("other mailbox owner")
recip.Resolve
Set Inbox = ns.GetSharedDefaultFolder(recip, olFolderInbox)