locked
VB.Net & EWS Managed API Beta RRS feed

  • Question

  • Sorry for the simplistic question, but I've been scratching my head for too long on this... I've taken some of the code samples in C# and converted them to VB.Net.  In this instance the following was converted:

    // Create an ExchangeService instance
    ExchangeService service = new ExchangeService();
    service.Credentials = new WebCredentials("user", "pwd", "domain");
    // Use the built-in Autodiscover client to automatically determine
    // the URL of the Exchange Web Services
    service.AutodiscoverUrl(user@contoso.com);


    IMPORTS Microsoft.Exchange.Webservices
    IMPORTS Microsoft.Exchange.Webservices.Data

    Sub Main()

    ' Create an ExchangeService instance
    Dim service As New ExchangeService()
    service.Credentials = New WebCredentials("user", "pwd", "domain")
    ' Use the built-in Autodiscover client to automatically determine
    ' the URL of the Exchange Web Services
    service.AutodiscoverUrl("user@contoso.com")

    End Sub

    But VS 2008 reports that "Type 'ExchangeService' is not defined"?  Am I missing something here?  I'd like to try this new API out...

    Thanks

    Wednesday, May 13, 2009 5:16 PM

Answers

  • Did you add the Microsoft.Exchange.WebServices.dll file as a Reference within your VS 2008 project (as described in the "Referencing the EWS Managed API Assembly" section of the Getting Started topic in the Exchange Web Services Managed API 1.0 Beta SDK)?

    Regards,
    Kim


    Programming Writer, Microsoft Exchange Developer Documentation Team
    • Marked as answer by Blocko Wednesday, May 13, 2009 6:06 PM
    Wednesday, May 13, 2009 5:26 PM

All replies

  • Did you add the Microsoft.Exchange.WebServices.dll file as a Reference within your VS 2008 project (as described in the "Referencing the EWS Managed API Assembly" section of the Getting Started topic in the Exchange Web Services Managed API 1.0 Beta SDK)?

    Regards,
    Kim


    Programming Writer, Microsoft Exchange Developer Documentation Team
    • Marked as answer by Blocko Wednesday, May 13, 2009 6:06 PM
    Wednesday, May 13, 2009 5:26 PM
  • I just realized that I forgot to include that.  Yes, I did add the .DLL as a reference to the project.
    Wednesday, May 13, 2009 5:27 PM
  • Please disregard; my error (as my face turns red).  I had commented out the Imports Microsoft.Exchange.Webservices.Data after getting ambiguous errors - I use this project as a test for EWS in general and had other code.

    Wednesday, May 13, 2009 5:31 PM
  • I'm unable to reproduce the error you're experiencing.  Here's what I did:

    1) Create a new VB.NET project (console application) in Visual Studio 2008.

    2) In the file Module1.vb (that opens up by default when you create a new VB.NET project in VS 2008), I added this code:

    Imports Microsoft.Exchange.Webservices
    Imports Microsoft.Exchange.Webservices.Data
    
    Module Module1
    
        Sub Main()
    
            ' Create an ExchangeService instance
            Dim service As New ExchangeService()
            service.Credentials = New WebCredentials("user", "pwd", "domain")
            ' Use the built-in Autodiscover client to automatically determine
            ' the URL of the Exchange Web Services
            service.AutodiscoverUrl("user@contoso.com")
    
        End Sub
    
    End Module
    

    3) I added Microsoft.Exchange.WebServices.dll as a Reference within the VS 2008 project (as described in the "Referencing the EWS Managed API Assembly" section of the Getting Started topic in the Exchange Web Services Managed API 1.0 Beta SDK).

    4) I successfully compiled (Build >> Build Solution) the VS.NET solution.  (No errors.)

    How does what you've done differ from the steps I've listed here?


    Programming Writer, Microsoft Exchange Developer Documentation Team
    Wednesday, May 13, 2009 6:03 PM
  • Please see my earlier reply.  I figured out my problem.  It now works correctly.  Thank you for your reply.
    Wednesday, May 13, 2009 6:06 PM