我正在尝试使用EWS访问我的电子邮件。它从Console应用程序正常工作。但是,当我尝试使用WCF服务访问同一段代码时,它给了我错误:
将请求作为没有邮箱的帐户发出时,必须为任何可分辨文件夹ID指定邮箱主SMTP地址
ExchangeService service = new ExchangeService();
service.Credentials = new WebCredentials("username", "password");
service.TraceEnabled = true;
service.AutodiscoverUrl("emailID");
FindItemsResults<Item> findResults = service.FindItems(
WellKnownFolderName.Inbox,
new ItemView(10));
非常感谢任何帮助
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITestService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://MachineIP/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ITestService" contract="ServiceReference1.ITestService"
name="BasicHttpBinding_ITestService" />
</client>
</system.serviceModel>
答案 0 :(得分:2)
在我的服务方法中,我禁用了模拟并修复了它
[OperationBehavior(Impersonation = ImpersonationOption.NotAllowed)]