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
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
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