来自Outlook宏的SenderName为空 [英] SenderName from Outlook macro is blank

查看:418
本文介绍了来自Outlook宏的SenderName为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 MailItem中获取 SenderName 属性, code>对象,但它们通过空白。

I want to get the SenderName and and To properties from a MailItem object, but they are coming through as blank.

我可以看到有$ code> SentOn 主题和其他不为空的属性。
有没有人知道为什么这两个是空白的?

I can see that there is SentOn, Subject and other properties which are not blank. Does anyone know why these two are blank?

这是我的代码:

Sub TestMacro()
Dim myOlApp As New Outlook.Application
Dim myOlexp As Outlook.Explorer

On Error Resume Next

Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
For Each myItem In myOlSel
strRawSubj = myItem.Subject
strSender = myItem.SenderName 'blank
strLongTo = myItem.To 'blank
Next
End Sub

编辑:
如果我以管理员身份运行Outlook,这可以工作。
是否可以获取这些值,而无需以管理员身份运行Outlook?

This works if I run Outlook as admin. Is it possible to get these values without having to run Outlook as admin?

推荐答案

...

使用常规模块上的代码

Option Explicit
Public Sub Example()
    Dim olMsg As mailitem

    Set olMsg = ActiveExplorer.Selection.Item(1)

    '// All print on Immediate Window
    Debug.Print olMsg.SenderName
    Debug.Print olMsg.sender
    Debug.Print olMsg.SenderEmailAddress
    Debug.Print olMsg.Categories
    Debug.Print olMsg.subject
    Debug.Print olMsg.To
    Debug.Print olMsg.CC
    Debug.Print olMsg.ReceivedByName
    Debug.Print olMsg.SenderEmailType

End Sub

这篇关于来自Outlook宏的SenderName为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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