EWS API中的OnEvent API在接收收件箱中的每一封电子邮件时监听两次,

时间:2019-07-02 06:00:57

标签: java exchangewebservices

我正在创建一个新的API,它将使用onEvent通知方法读取电子邮件,然后将邮件发送到另一封电子邮件。在将邮件发送到另一封邮件时,它发送了两次。

我试图通过将ID存储在哈希映射中并在ID匹配ID时第二次触发通知方法时第二次检查ID来筛选出ID,但我不会发送邮件。但这不能正常工作。

我的流式通知:


StreamingSubscription subscription = exchangeService.subscribeToStreamingNotification(folder,EventType.NewMail);  
StreamingSubscriptionConnection conn = new StreamingSubscriptionConnection(exchangeService,30); conn.addSubscription(subscription );  
conn.addNotificationEvent(new StreamingsubscriptionConnection.INotificationEventDelegate())
    { @override 
    public void notificationEventDelegate(object sender, NotificationEventArgs args){
         StreamingSubscription subscription = args.getSubscription(); 
            for(NotificationEvent event : args.getEvents()){
                 if(event instanceof FolderEvent){
                     FolderEvent folderEvent = (FolderEvent) event; 
                 } else if (event instanceof ItemEvent){
                     ItemEvent itemEvent = (ItemEvent) event; } else{ logger.error("Unsupported event" + event.getClass)
                 }
else{
 logger.error("Unsupported event" + event.getClass) 
}

0 个答案:

没有答案
相关问题