通过EWS API连接到outlook.com邮箱 [英] Connect to outlook.com mailbox via EWS API

查看:284
本文介绍了通过EWS API连接到outlook.com邮箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



您能告诉我是否可以通过EWS连接到outlook.com邮箱API。


我可以通过API连接到我的Office 365公司帐户,但不能连接到outlook.com帐户。


我启用了POP on邮箱,但仍然没有运气。


 ExchangeService service = new ExchangeService(); 

service.Credentials = new NetworkCredential(" myEmail@outlook.com"," MyPassword");
service.UseDefaultCredentials = false;

service.AutodiscoverUrl(" myEmail@outlook.com",RedirectionUrlValidationCallback); //在这里失败,下面是异常消息

FindItemsResults< Item> findResults = service.FindItems(WellKnownFolderName.Inbox,new ItemView(20));


 private static bool RedirectionUrlValidationCallback(string redirectionUrl)
{
//验证回调的默认值是拒绝URL。
bool result = false;

Uri redirectionUri = new Uri(redirectionUrl);

//验证重定向URL的内容。在这个简单的验证
//回调中,如果重定向URL使用HTTPS
//加密身份验证凭据,则认为重定向URL有效。
if(redirectionUri.Scheme ==" https")
{
result = true;
}

返回结果;
}

异常消息:


预期的XML节点类型是XmlDeclaration,但是实际类型是元素。



提前致谢。

解决方案

< blockquote>

嗨Johan,


EWS仅支持Office 365,不支持outlook.com。 我们有一个

REST API
,也适用于Office 365,但最终也将支持Outlook.com用户。 但是,我们还没有时间表来分享outlook.com的支持。 希望有帮助......


谢谢,


Venkat



Hi guys,

Can you tell me if it is possible to connect to a outlook.com mailbox via the EWS API.

I can connect to my office 365 company account via the API, but not the outlook.com account.

I have enabled POP on the mailbox, but still no luck.

ExchangeService service = new ExchangeService();

            service.Credentials = new NetworkCredential("myEmail@outlook.com", "MyPassword");
            service.UseDefaultCredentials = false;

service.AutodiscoverUrl("myEmail@outlook.com", RedirectionUrlValidationCallback); // Fails here with below exception message

FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(20));

private static bool RedirectionUrlValidationCallback(string redirectionUrl)
        {
            // The default for the validation callback is to reject the URL.
            bool result = false;

            Uri redirectionUri = new Uri(redirectionUrl);

            // Validate the contents of the redirection URL. In this simple validation
            // callback, the redirection URL is considered valid if it is using HTTPS
            // to encrypt the authentication credentials. 
            if (redirectionUri.Scheme == "https")
            {
                result = true;
            }

            return result;
        }

Exception Message:

The expected XML node type was XmlDeclaration, but the actual type is Element.

Thanks in advance.

解决方案

Hi Johan,

EWS is only supported for Office 365 and not supported for outlook.com.  We have a REST API that also works for Office 365 only, but will eventually support Outlook.com users as well.  However, we don't yet have a timeline to share for outlook.com support.  Hope that helps ...

Thanks,

Venkat



这篇关于通过EWS API连接到outlook.com邮箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆