开发者

ExchangeServiceBinding namespace error

开发者 https://www.devze.com 2023-03-27 05:46 出处:网络
Summary: application will not accept the ExchangeServiceBinding command. Details: I am trying to loop through a very large mailbox, so I am using an index to break the inbox into 200 email chunks.

Summary: application will not accept the ExchangeServiceBinding command.


Details:

I am trying to loop through a very large mailbox, so I am using an index to break the inbox into 200 email chunks. The only example I could find (shown below) keeps returning

the type or namespace name “ExchangeServiceBinding” could not be found (are you missing a using directive or an assembly reference? )

Which I find strange, because I am using it using Microsoft.Exchange.WebServices;. Any ideas or help is greatly appreciated. I am running Windows 7 and Visual Studio 2010 and trying to access Exchange 2007 mailboxes.


Things I've tried:

  • searching Google
  • searching Stack Overflow
  • searching MSDN
  • slamming my head on my desk
  • trial and error

Code:

// Create binding variable to be used for GetItemsFromInbox().
// Set up the binding with credentials and URL.
ExchangeServiceBinding binding = new ExchangeServiceBinding();
binding.Credenti开发者_如何学编程als = new NetworkCredential(dUser, dPassword, dDomain);
binding.Url = new Uri("https://" + ExchangeServerName + "/EWS/Exchange.asmx");

// Set up the binding for Exchange impersonation.
binding.ExchangeImpersonation = new ExchangeImpersonationType();
binding.ExchangeImpersonation.ConnectingSID = new ConnectingSIDType();
binding.ExchangeImpersonation.ConnectingSID.PrimarySmtpAddress = "mailboxnamehere”;

// Call GetItemsFromInbox()
int index = 0;
bool looping = true;

while (looping)
{
    List<ItemType> items = GetItemsFromInbox(binding, index, 200, index);
    if (items == null || items.count == 0)
    {
        looping = false;
        break;
    }
    // Do your work here
}


Instead of the Exchange Web Services, use the Exchange Managed API.

SDK: http://msdn.microsoft.com/en-us/library/dd633710(v=exchg.80).aspx
Download: http://www.microsoft.com/download/en/details.aspx?id=13480

It's much easier to use than the WebServices.


I found my error. This methodology only works for Exchange 2010. Since I am running Exchange 2007 I will have to figure out a completely different way to make this work.

Thank you everyone for you help, I really appreciate it.


You should add a WebReference to your solution to the exchange WebService. https://exchaneServerName/EWS/Exchange.asmx


ExchangeServiceBinding is contained into the ews.dll. According to your error, you didn't add a reference to this DLL file.

More information about Generating Exchange Web Services Proxy Classes:

So now you have a code file with the autogenerated proxies. Next, you compile your code file into an assembly for use in your Exchange Web Services projects. The C# compiler is available with the Visual Studio 2005 Command Prompt. Assuming that you named your code file EWS.cs, you can run the following command at the command prompt to compile your code into an assembly:

csc /target:library /out:EWS.dll EWS.cs

Notice that EWS.dll is the name of the compiled assembly. This is how EWS.dll is created.

0

精彩评论

暂无评论...
验证码 换一张
取 消