email - 来自 WebSite 的 EWS 使用内部网的用户凭据和 Windows 身份验证

标签 email authentication exchangewebservices intranet integrated

我想了解我应该如何配置需要传递用户凭据并获取一些邮件内容的网站 (ASP.Net)

根据应用程序池配置,我会收到不同类型的错误, 完成它的完整方法是什么?我的意思是代码 + 配置 ;o)

我不想写用户名和密码,而是通过windows认证得到的

谢谢

代码:

Service = new ExchangeService(ExchangeVersion.Exchange2010_SP2)
            {
                Url =
                    new Uri(
                    "https://xxx/yyy.asmx"),
                //UseDefaultCredentials = true doesnt help
            };
        var view = new ItemView(1820);

        // Find the first email message in the Inbox that has attachments. This results
        FindItemsResults<Item> results = Service.FindItems(folderName, view); 
        //Here I get the error 401

最佳答案

看看Get started with EWS Managed API client applications ,它涵盖了让您入门和滚动的基础知识。请注意,当您使用 UseDefaultCredentials 时,您必须在加入域的计算机上,用户已登录,并且您必须以本地服务器为目标。我们测试了该场景,以下代码适用于该场景。

using System;
using Microsoft.Exchange.WebServices.Data;

namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
            service.UseDefaultCredentials = true;
            service.TraceEnabled = true;
            service.TraceFlags = TraceFlags.All;
            //Replace the URL below with your own, but using AutoDiscover is recommended instead
            service.Url = new Uri("https://computer.domain.contoso.com/EWS/Exchange.asmx");

            FindItemsResults<Item> results = service.FindItems(WellKnownFolderName.Inbox,
                                                               new ItemView(1));
        }
    }
}

如果这对您不起作用,那么您可能想尝试使用模拟。参见 this thread ,我认为他们有类似的情况。有关模拟的更多信息,请访问 MSDN:Impersonation and EWS in Exchange .

关于email - 来自 WebSite 的 EWS 使用内部网的用户凭据和 Windows 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24674720/

相关文章:

PHP 从 html 消息发送电子邮件

html - 在电子邮件模板内部包含外部样式表

html - Outlook 2013 中的电子邮件通讯第一个空表格单元格高度问题

php - 可以一起使用 Zend_Http_Client() 和 Zend_Rest_Client()

vb.net - 尝试使用 .ResolveName 时出现 EWS 错误

web-services - Grails:不同格式的RESTful Web服务数据处理

python - 有没有办法检查网站使用的身份验证类型?

python-3.x - 'AssertionError' 对象没有属性 'message'

php - Cakephp 身份验证重定向问题

Android:webview 可以自动登录 App Engine 应用程序吗?