Folder.Items 中缺少发件人、发件人电子邮件地址 [英] Sender, SenderEmailAddress Missing in Folder.Items

查看:45
本文介绍了Folder.Items 中缺少发件人、发件人电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 Outlook 电子邮件中下载附件.

I want to download attachments from Outlook emails.

这是我用来检索电子邮件的代码.

Here is the code I am using to retrieve emails.

Set OutlookApp = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox).Folders(botMailFolder)

i = 1

For Each OutlookMail In Folder.Items
    If InStr(OutlookMail.Subject, " ") <> 0 Then

        If OutlookMail.Attachments.Count > 0 Then

            Dim folderBase As String
            folderBase = botLocalFolder

            Dim newFolder As String
            newFolder = folderBase & OutlookMail.EntryID

            'OutlookItem.SenderAddress

            If Not FolderExists(newFolder) Then
                FolderCreate newFolder
            End If

            For Each a In OutlookMail.Attachments
                Dim newFileName As String
                newFileName = newFolder & "" & a.DisplayName
                'MsgBox newFileName
                a.SaveAsFile newFileName
            Next

        End If

    End If

Next OutlookMail

问题是,SenderSenderEmailAddressSenderName 为空.仅 SenderEmailType 填充为 EX.

The problem is, Sender,SenderEmailAddress and SenderName are empty. Only SenderEmailType is populated as EX.

代码作为 Excel 宏执行,我所有的发件人(用户)都是 Exchange 2013 用户.

The code is executed as an Excel macro and all my senders (users) are Exchange 2013 users.

如何找到电子邮件项目发件人的电子邮件地址和姓名?

How can I find email address and name for the sender of an email item?

这是我在本地窗口看到的内容.

Here is what I see on my locals window.

这适用于框中的所有电子邮件.有人告诉我这是因为所有人都是交换用户",企业管理员可以对他们进行限制.

This happens for all emails in the box. Someone told me it is because all are "exchange users" and for them enterprise admins can put restrictions.

推荐答案

我也遇到了这个问题.我可以通过它的唯一方法是在 OUTLOOK VBA 中运行代码(Outlook -> 开发人员选项卡 -> vba),并且不要专门将您的应用程序作为 Outlook 应用程序启动.

I had this issue as well. The only way I could get past it is by running the code IN OUTLOOK VBA (Outlook -> developer tab -> vba), and do not start your application specifically as an outlook application.

示例:

Dim olApp As Outlook.Application
Set olApp = CreateObject(Outlook.Application)

需要成为

Dim olApp As Application
Set olApp = Application

诀窍是不要从外部 Outlook(IE. 在 Excel 中)打开新的 Outlook 实例.如果您有任何类型的 Outlook Exchange 安全设置,从 Excel 中打开 Outlook 将禁止您访问诸如发件人之类的关键信息.

The trick is to NOT open a new instance of outlook from outside outlook (IE. in Excel). If you've got any type of Outlook Exchange security settings, opening outlook from excel will prohibit you from accessing key pieces of information such as sender.

这篇关于Folder.Items 中缺少发件人、发件人电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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