摘要:应用程序不接受ExchangeServiceBinding
命令。
详细说明:
我正在尝试遍历一个非常大的邮箱,因此我使用索引将收件箱分成200个电子邮件块。我能找到的唯一例子(如下所示)不断返回
找不到类型或命名空间名称“ExchangeServiceBinding”(您是否缺少using指令或程序集引用?)
我觉得很奇怪,因为我正在使用它using Microsoft.Exchange.WebServices;
。非常感谢任何想法或帮助。我正在运行Windows 7和Visual Studio 2010并尝试访问Exchange 2007邮箱。
我尝试过的事情:
代码:
// 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
}
答案 0 :(得分:1)
使用Exchange托管API代替Exchange Web服务。
SDK:http://msdn.microsoft.com/en-us/library/dd633710(v=exchg.80).aspx
下载:http://www.microsoft.com/download/en/details.aspx?id=13480
它比WebServices更容易使用。
答案 1 :(得分:1)
我发现了我的错误。此方法仅适用于Exchange 2010.由于我正在运行Exchange 2007,因此我必须找出一种完全不同的方法来使其工作。
谢谢大家的帮助,我真的很感激。
答案 2 :(得分:0)
ExchangeServiceBinding
包含在ews.dll
中。根据您的错误,您没有添加对此DLL文件的引用。
有关Generating Exchange Web Services Proxy Classes的更多信息:
所以现在你有一个带有自动生成代理的代码文件。接下来,将代码文件编译为程序集,以便在Exchange Web服务项目中使用。 Visual Studio 2005命令提示符提供了C#编译器。假设您将代码文件命名为EWS.cs,则可以在命令提示符处运行以下命令将代码编译为程序集:
csc /target:library /out:EWS.dll EWS.cs
请注意,EWS.dll是已编译程序集的名称。这就是EWS.dll的创建方式。
答案 3 :(得分:0)
您应该将Web引用添加到Exchange Web Service的解决方案中。 https://exchaneServerName/EWS/Exchange.asmx