Via the COM parts of pywin32
, you need to get Outlook's Application object, and from it its attribute Session
, which gives you the Namespace object (the GetNamespace
method should also work for the same purpose, when called with the only supported argument value, 'MAPI'
). From there you can use the Accounts
property to get the Accounts object, which is a typical COM collection -- indexable via Item
up to its Count
. You loop over it and check each Account object: each has two properties of interest -- a UserName
(the string you want to check for equality to the "shorter login name") and a DisplayName
-- the string you desire.
Yes, this is incredibly long and convoluted, but, that's par for the course for the COM interfaces that MS applications offer. For all I know there might be leaner way in recent Outlook releases -- this is the long and gnarled way that's been working for a long time (these days I don't even have a Windows install handy to check this out and write the Python for you...!-)