从WCF运行时发生EWS错误

本文关键字:EWS 错误 WCF 运行时 | 更新日期: 2023-09-27 18:25:04

我正试图使用EWS访问我的电子邮件。它在控制台应用程序中运行良好。但当我试图使用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));

将非常感谢任何帮助

编辑1:我从WP7应用程序调用此WCF服务,这里是ServiceReferences.ClientConfig设置

    <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>

从WCF运行时发生EWS错误

在我的服务方法中,我禁用了模拟,它得到了修复的

[OperationBehavior(Impersonation = ImpersonationOption.NotAllowed)]