Search code examples
c#outlook-addin

Retrieving email server software name


I wrote an Outlook (2010+) C# add-in and having some trouble with different email servers. As I found specific solutions for each server type I would like to know if there is an way to get the information to which email server an Outlook account points? It would be totally sufficient to get the name of the underlying email server software as version numbers are not neccessary to know.

Something like

string serverSoftware = account.server.softwareName; 

would be great...


Solution

  • You can look for the accounts clsid or service name in the registry.

    For Outlook 2010 and earlier:

    HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\{0}\9375CFF0413111d3B88A00104B2A6676

    For Outlook 2013:

    HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\{0}\9375CFF0413111d3B88A00104B2A6676

    You have to replace {0} by Account.Session.CurrentProfileName

    In this location iterate all subkeys and look for the "Account Name", that will match to Account.DisplayName

    Okay, now it's getting a bit more difficult:

    First check the value of "clsid" against this list:

    • {ED475411-B0D6-11D2-8C3B-00104B2A6676} = Pop3
    • {ED475412-B0D6-11D2-8C3B-00104B2A6676} = IMAP
    • {ED475415-B0D6-11D2-8C3B-00104B2A6676} = Active Sync (Outlook 2013)
    • {ED475414-B0D6-11D2-8C3B-00104B2A6676} = Exchange and other MAPI-like third-party

    In case of the last clsid, check "Service Name". For Exchange accounts, it will be "MSEMS", while i.e. a Kerio Connect account would return "KERIOOCF" as service name.