xtawgipl 2016-04-10 13:56 采纳率: 0%
浏览 5318
已结题

微软exchange 2013 怎么赋予查看所有用户(邮箱用户)的邮件的权限

最近在做exchange 2013开发,需要查所有exchange 2013用户有收到邮件时都响应某功能,
现在可以监控某一个用户,当监控所有用户时报 未声明“SubscribeToAllFolders”特性。 错误
以下是代码:
public class NewMailNotification {
public static void main(String[] args) {
try {
Service service = new Service("https://test.cn/EWS/Exchange.asmx", "administrator", "123456");

        String newWatermark = null;

        PullSubscription subscription = new PullSubscription(true, EventType.NEW_MAIL);

        // initial subscribe
        SubscribeResponse subscribeResponse = service.subscribe(subscription);

        while (true) {
            Thread.currentThread().join(1000);

            GetEventsResponse eventsResponse = service.getEvents(subscribeResponse);

            Notification notification = eventsResponse.getNotification();

            for (int i = 0; i < notification.getEvents().size(); i++) {
                newWatermark = notification.getEvents().get(i).getWatermark();
                System.out.println("newWatermark = " + newWatermark);

                if (notification.getEvents().get(i) instanceof NewMailEvent) {
                    NewMailEvent newMailEvent = (NewMailEvent) notification.getEvents().get(i);

                    ItemId itemId = (ItemId) newMailEvent.getId();

                    Message message = service.getMessage(itemId);

                    System.out.println(message.getSubject());
                    System.out.println(message.getReceivedTime());
                    Method[] methods = message.getClass().getMethods();
                    for(Method method : methods){
                        if(method.getName().contains("get") && method.getParameterCount() == 0){
                            Object o = null;
                            try {
                                o = method.invoke(message);
                                if(o == null){
                                    //System.out.println(method.getName() + " --> null");
                                }else{
                                    //System.out.println(method.getName() + " --> " + o.toString());
                                }
                            } catch (IllegalAccessException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            } catch (IllegalArgumentException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            } catch (InvocationTargetException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                    }
                }
            }

            // resubscribe with new watermark
            subscription.setWatermark(newWatermark);
            subscribeResponse = service.subscribe(subscription);
        }
    } catch (ServiceException e) {
        System.out.println(e.getMessage());
        System.out.println(e.getXmlMessage());

        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

}
请问SubscribeToAllFolders权限怎么赋予

  • 写回答

2条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序