Exchange Server的推/拉通知 [英] Push / Pull notification of Exchange Server

查看:112
本文介绍了Exchange Server的推/拉通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我正在创建一项连接到Exchange服务并从那里获取新邮件的服务。当我手动执行代码时,我可以从那里获得新邮件。我需要收到邮件到收件箱。为了达到这个要求,我想使用EWS API的推送通知。

我已为此编写代码,但我没有收到任何新邮件和通知事件。这是一段代码:



我从以下链接获得了帮助:

EWS邮件通知程序 [ ^ ]

Hi
I am creating a service which connect to Exchange service and get new mail from there. I am able to get new mail from there when I execute the code manually. I need to get mail as it come to inbox. To achieve this requirement I want to use Push notification of EWS API.
I have written code for this, but I do not get any event for new mail and notification. Here is the piece of code:

I got help from the following link:
EWS Mail Notifier[^]

{
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(
                   Object obj,
                   X509Certificate certificate,
                   X509Chain chain,
                   SslPolicyErrors errors)
                {
                    return true;
                    // TODO: check for a valid certificate
                };
                ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
                service.Credentials = new NetworkCredential("xxxx", "xxxx", "abc.com");
                service.Url = new Uri("https://mail.abc.com/owa/Exchange.asmx");
                service.AutodiscoverUrl("xxxx@abc.com");
               
                ServicePointManager.ServerCertificateValidationCallback = new    System.Net.Security.RemoteCertificateValidationCallback(delegate { return true; });
                AuthenticateSecureOWA("mail.abc.com", "abc.com", "xxxx", "xxxx");
                ItemView IView = new ItemView(10);
               
                FindItemsResults<Item> findResults;
                findResults = service.FindItems(WellKnownFolderName.Inbox, IView);

                PushSubscription ps = service.SubscribeToPushNotifications(
                new FolderId[] { WellKnownFolderName.Inbox },
                new Uri("http://192.168.1.1:5050"),
                5 , null ,  EventType.NewMail);
                SubscriptionId = ps.Id;
                _listener = new TcpListener(5050);
                _listener.Start();
                _th = new Thread(new ThreadStart(ProcessIncomingMessages));
                _th.Start();

}


 private void ProcessIncomingMessages()
        {
            try
            {
                for (; ; )
                {
                    CSHTTPRequest csHttpRequest = new CSHTTPRequest(_listener.AcceptTcpClient(), this);

                    csHttpRequest.Process();
                   
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }



我正在使用其他一些支持文件来处理。



任何建议将不胜感激

提前致谢。


There are some other supporting files I am using to process.

Any suggestion will be appreciated
Thanks in advance.

推荐答案

EWS网址具有以下形式:



https:// xbcom / EWS /Exchange.asmx。



此处的链接说明了交换服务网址的格式:



http://msdn.microsoft.com/en-us/library/dd633692%28v=exchg .80%29.aspx [ ^ ]



你用过



https ://mail.abc.com/ owa /Exchange.asmx





希望它有所帮助。
EWS urls have the following form:

"https://x.b.com/EWS/Exchange.asmx".

The link here talks about the format of the exchange service url:

http://msdn.microsoft.com/en-us/library/dd633692%28v=exchg.80%29.aspx[^]

You've used

"https://mail.abc.com/owa/Exchange.asmx"


Hope it helps.


你解决了这个问题吗?



我也面临这个问题。



请帮助我,如果你得到它
Did you solved this problem?

I am also facing this.

Please help me, if you got it


这篇关于Exchange Server的推/拉通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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