使用Microsoft Access,需要从其他帐户的Outlook电子邮件中提取附件 [英] Using Microsoft Access, need to pull attachments from Outlook emails of a different account

查看:124
本文介绍了使用Microsoft Access,需要从其他帐户的Outlook电子邮件中提取附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面有工作代码可以从我自己的Outlook电子邮件帐户中提取附件,但是我需要对其他帐户执行此操作,该帐户设置为自动流程的默认回复电子邮件框.

I have working code below to extract attachments from my own Outlook email account, however I need to do it for a different account that is setup as a default reply email box for an automated process.

我不确定如何告诉下面的代码检查该邮箱,而不是我自己的邮箱.我尝试过设置Inbox变量的各种变体,但是到目前为止,它们都没有起作用.这是在Access 2013中完成的.

I'm not entirely sure how to tell the code below to check for that mailbox instead of my own. I've tried different variations of setting the Inbox variable, but none of them have worked thus far. This is done within 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")

这篇关于使用Microsoft Access,需要从其他帐户的Outlook电子邮件中提取附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆