SenderName from Outlook macro is blank

后端 未结 2 1825
生来不讨喜
生来不讨喜 2021-01-25 18:33

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

I can see that th

相关标签:
2条回答
  • 2021-01-25 19:04

    Try the following...

    Use the code on regular module

    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
    
    0 讨论(0)
  • 2021-01-25 19:07

    try this please

    Sub TestMacro()
    
        Dim myOlexp As Outlook.Explorer
        Dim myOlSel As Selection
    
    '   On Error Resume Next                       ' do not use during development ... hides errors
    
        Set myOlexp = Application.ActiveExplorer   ' "Application" object already exists
        Set myOlSel = myOlexp.Selection
    
        For Each myItem In myOlSel
            Debug.Print Len(myItem.Subject)        ' print the length of each string
            Debug.Print Len(myItem.SenderName)     ' maybe the strings are being obfuscated somehow
            Debug.Print Len(myItem.To)
        Next
    
        Set myOlSel = Nothing
        Set myOlexp = Nothing
    
    End Sub
    
    0 讨论(0)
提交回复
热议问题