How to connect to ExchangeServer from (using c#)? RRS feed

  • Question

  • This is the code I use to connect to ExchangeServer. I don't get any bug nor some result. I have an account with 2 mailboxes.

     Can someone help me, please?

    static void Main(string[] args)
    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

    .Credentials = new NetworkCredential( "{Active Directory ID}", "{Password}", "{Domain Name}" );


    FindItemsResults<Item> findResults = service.FindItems(
    new ItemView(10));

    foreach (Item item in findResults.Items)
    Friday, February 18, 2011 2:42 PM

All replies

  • Have you tried without the autodiscover method, by setting directly the uri:


       m_service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
       m_service.Credentials = new WebCredentials(sUser, sPwd, sDomain);
       m_service.Url = new Uri("http://192.168.X.X/EWS/Exchange.asmx");
        FolderView folderView = new FolderView(1);
        folderView.Traversal = FolderTraversal.Deep;
        FindFoldersResults results = null;
        results = m_service.FindFolders(WellKnownFolderName.Root, folderView);
        if (results.TotalCount <= 0)
         bSuccess = false;
       catch (Exception ex)
        bSuccess = false;


    Here I retrieve folders, I'm sure I have at least a result I don't know if you are sure to have items in your inbox.

    I'm using Exchange 2010SP1 though, maybe it makes a difference. (And this isn't made for ASP.Net but for my C# form app)


    Tuesday, February 22, 2011 4:11 PM