2011-08-10 139 views
1

摘要:应用程序不会接受ExchangeServiceBinding命令。ExchangeServiceBinding命名空间错误


详情:

我通过一个非常大的邮箱试图循环,所以我使用的是指数突破收件箱到200个邮件块。我能找到的唯一的例子(如下所示)保持返回

类型或命名空间名称“ExchangeServiceBinding”找不到(是否缺少using指令或程序集引用?)

哪我觉得很奇怪,因为我使用它using Microsoft.Exchange.WebServices;。任何想法或帮助,不胜感激。我正在运行Windows和Outlook 2007,并尝试访问Exchange 2007邮箱。


事情我已经尝试:

  • 谷歌搜索
  • 搜索堆栈溢出 
  • 搜索MSDN
  • 砰我的头放在我的桌子
  • 试错

代码:

// Create binding variable to be used for GetItemsFromInbox(). 
// Set up the binding with credentials and URL. 
ExchangeServiceBinding binding = new ExchangeServiceBinding(); 
binding.Credentials = 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 
} 
+1

您的项目是否参考ews程序集? –

+0

是的。使用Microsoft.Exchange.WebServices; using Microsoft.Exchange.WebServices.Data; using Microsoft.Exchange.WebServices.Autodiscover; – toosweetnitemare

回答

1

我发现我的错误。此方法仅适用于Exchange 2010.因为我运行的是Exchange 2007,所以我必须找出一种完全不同的方法来完成此项工作。

谢谢大家的帮助,我真的很感激。

0

ExchangeServiceBinding被包含到ews.dll。根据您的错误,您没有添加对此DLL文件的引用。

更多有关Generating Exchange Web Services Proxy Classes

所以,现在你有一个自动生成的代理代码文件。接下来,将代码文件编译为一个程序集,以便在您的Exchange Web Services项目中使用。 C#编译器可用于Visual Studio 2005命令提示符。假设你命名你的代码文件EWS.cs,你可以在命令提示符下运行以下命令编译代码到一个程序:

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

注意EWS.dll是的名称编译汇编。这是如何创建EWS.dll。

+0

我的机器搜索空了这个DLL。任何想法,如果它在微软的ews包还是我必须以某种方式生成它? – toosweetnitemare

+0

@toosweetnitemare提供指示链接。 – VMAtm

+0

ty。我只是在看这个:)让我们希望它的作品。 – toosweetnitemare

1

而不是Exchange Web服务,使用Exchange托管API。

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

它更容易比WebServices的使用。

+0

你能否详细说说更易用? – toosweetnitemare

+0

也是即时通讯使用。不是那个相同的东西? – toosweetnitemare

+0

EWS托管API封装了Exchange Web服务并提供了一个很好的对象模型。使用更直观。 –