A while back I wrote a basic application which did Autodiscover using the Exchange Managed API and provided some minimal logging.  The tool is called Autodiscover Checker and the full code for it can be found on code.msdn.microsoft.com.  Over time I have added a lot more to this application by adding more ways to do Autodiscover against Exchange and by improving the logging. Last week I published the 2.2 release.

As of the 2.2 release, the code now shows how to do Autodiscover using:

The Exchange Managed API's Service object.

The Exchange Managed API's Autodiscover object.

Raw C# code which does POX Autodiscover

Raw C# code which does SOAP Autodiscover

Raw C# code which does SCP Lookups

The original code used for POX and SCP came from the Microsoft Exchange WebServices SDK for Exchange 2010 (September 2011).  So, you could use the SDK as another source of reference code for POX and SCP work.

I ran into a couple of issues with the Exchange Managed API 2.0.  The first was where the service object seemed to go into a redirect loop when there was a redirect email address being returned during Autodiscover.  The second issue is that it was not sending credentials at a specific point of doing Autodiscover and the server I was going against had credentials required.  I implemented a work-around to this - see the processing tied to the "Work-around Address Redirect Issue" I've added to the "Exchange Managed API Checker" window.

Autodiscover Checker 2.2
http://code.msdn.microsoft.com/office/Autodiscover-Checker-e1ebca42/view/SourceCode 

So, if your looking for code to use in your application or need a sample to refer to then please check out this apps code. In addition to its code, it can also be used for troubleshooting.