C# ExchangeServiceBinding命名空间错误
摘要:应用程序将不接受C# ExchangeServiceBinding命名空间错误,c#,.net,namespaces,exchangewebservices,C#,.net,Namespaces,Exchangewebservices,摘要:应用程序将不接受ExchangeServiceBinding命令 详情: 我试图在一个非常大的邮箱中循环,所以我使用索引将收件箱分成200个电子邮件块。我能找到的唯一例子(如下所示)不断返回 找不到类型或命名空间名称“ExchangeServiceBinding”(是否缺少using指令或程序集引用?) 我觉得很奇怪,因为我使用的是Microsoft.Exchange.WebServices。非常感谢您的任何想法或帮助。我正在运行Windows7和Visual Studio 2010,并
ExchangeServiceBinding
命令
详情: 我试图在一个非常大的邮箱中循环,所以我使用索引将收件箱分成200个电子邮件块。我能找到的唯一例子(如下所示)不断返回 找不到类型或命名空间名称“ExchangeServiceBinding”(是否缺少using指令或程序集引用?) 我觉得很奇怪,因为我使用的是Microsoft.Exchange.WebServices代码>。非常感谢您的任何想法或帮助。我正在运行Windows7和Visual Studio 2010,并尝试访问Exchange 2007邮箱
我尝试过的事情:
- 搜索谷歌
- 搜索堆栈溢出
- 搜索MSDN
- 把头撞在桌子上
- 反复试验
代码:
//创建用于GetItemsFromInbox()的绑定变量。
//使用凭据和URL设置绑定。
ExchangeServiceBinding=新的ExchangeServiceBinding();
binding.Credentials=newnetworkcredential(dUser、dPassword、dDomain);
binding.Url=新Uri(“https://“+ExchangeServerName+”/EWS/Exchange.asmx”);
//设置Exchange模拟的绑定。
binding.ExchangeImpersonation=新的ExchangeImpersonationType();
binding.ExchangeImpersonation.ConnectionSid=新的ConnectionSidType();
binding.ExchangeImpersonation.ConnectingSID.PrimarySmtpAddress=“mailboxnamehere”;
//调用GetItemsFromInbox()
int指数=0;
布尔循环=真;
while(循环)
{
列表项=GetItemsFromInbox(绑定,索引,200,索引);
if(items==null | | items.count==0)
{
循环=假;
打破
}
//你在这里工作吗
}
包含在ews.dll
中。根据您的错误,您没有添加对此dll文件的引用
更多关于:
现在,您有了一个带有自动生成代理的代码文件。接下来,将代码文件编译成程序集,以便在Exchange Web服务项目中使用。Visual Studio 2005命令提示符下提供了C#编译器。假设您将代码文件命名为EWS.cs,则可以在命令提示符下运行以下命令来编译y将我们的代码导入程序集:
请注意,EWS.dll是已编译程序集的名称。这是创建EWS.dll的方式
您应该将解决方案的WebReference添加到exchange Web服务中。
使用Exchange托管API代替Exchange Web服务 SDK:
下载:
它比Web服务更易于使用。我发现了我的错误。此方法仅适用于Exchange 2010。由于我正在运行Exchange 2007,因此我必须找到一种完全不同的方法来实现此功能
谢谢大家的帮助,我非常感谢。您的项目引用了ews程序集吗?是的。使用Microsoft.Exchange.WebServices;使用Microsoft.Exchange.WebServices.Data;使用Microsoft.Exchange.WebServices.Autodiscover;这是服务引用还是仅仅是引用?搜索我的计算机时,该dll显示为空。你知道它是在微软的ews软件包中,还是我必须以某种方式生成它吗?@toosweetnitemare提供了指向说明的链接。ty.我只是在看:)希望它能工作。那不起作用。实际上我的应用程序中已经有了名为exchangeServiceEWS的webreference。@toosweetnitemare你读过整个艺术吗icle?添加引用后,您需要编译ews.dllca,您可以详细说明它更易于使用吗?这也是我使用的ews。这不是一回事吗?ews托管API封装了Exchange Web服务并提供了一个很好的对象模型。使用起来更直观。
// 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
}
csc /target:library /out:EWS.dll EWS.cs