none
just trying to connect to exchange 2013 using C# console... RRS feed

  • Question

  • I'm trying to connect to a mailbox on the exchange 2013 server to grab, move attachments and then remove email.
    So I figured I start with the basic..  installed the MS Exchange Reference libraries..
    Using MS exact code example online..it doesn't work at all.  I get error: need to find webcredentials.cs, when i'm try to verify that so far everything that is working (debug stepping)..
    What I need to do..- first get to server, next get to mailbox, next find first email, move attachment, delete email and get next email (loop)...
    But I keep getting a error and to be honest, I have no idea why it's appearing.

    using Microsoft.Exchange.WebServices.Autodiscover;
    using Microsoft.Exchange.WebServices.Data;
    using Microsoft.Exchange.WebServices.Auth;

    namespace Exchange2
    {
        class Program
        {
            static void Main(string[] args)
            {
                ExchangeService service = new ExchangeService();
                service.Credentials = new WebCredentials("user@domain.com", "Pa$$w0rd");
                service.AutodiscoverUrl("user@domain.com");

     }
        }
    }

    Can anyone help this newbie?

    Wednesday, July 1, 2015 4:42 PM

All replies

  • What's the exact error and on what line does it occur?

    My first thought is that maybe it doesn't like the default ExchangeService constructor. Have you tried using the overloaded constructor that allows you to specify the version of the Exchange Server instance you're connecting to?

    Wednesday, July 1, 2015 6:41 PM
  • ExchangeService.cs not found..

    the a dialog box appears for me to browse to it...
    but it doesn't exist. All the code is written above

    ..so confused

    Wednesday, July 1, 2015 7:36 PM
  • I'm afraid I'm not following you.

    You make it sound like you are able to run the program, but your error sounds like a compilation error, not a run-time error.

    Are you able to compile the program? If so, what line causes the program to throw that error?

    Wednesday, July 1, 2015 7:51 PM