且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Exchange Web服务,在Android上的错误

更新时间:2023-12-03 20:35:58

有名额 JWebServices的Java商业ActiveSync的图书馆,机器人。在该页面下载JWebServices的Exchange。一旦你下载,只要jwebservices-1.1.jar JAR文件添加到乌尔项目和u只需要提供信息,同时创造在乌拉圭回合code中的服务对象,如下图所示。它曾在我的Andr​​oid应用程序。

There's a commercial ActiveSync library available @ JWebServices for java and android. Download JWebServices for Exchange in that page. Once you download , Just add jwebservices-1.1.jar jar file to ur project and u just have to provide the info while creating the Service object in ur code, as shown below. It worked in my android app.

Service服务=新服务(                         https://mail.yourdomain.com/ews/Exchange.asmx                         emailid@yourdomain.com,密码);

Service service = new Service( "https://mail.yourdomain.com/ews/Exchange.asmx", "emailid@yourdomain.com", "password");

下面是例子code,显示当前时间和未来12小时的预约。

Here is the example code to display the appointments between current time and next 12 hours.

Service service = new Service(
                    "https://mail.yourdomain.com/ews/Exchange.asmx",
                    "emailid@yourdomain.com", "password");
            Date startDate = new Date(System.currentTimeMillis());
            Date endDate = new Date(System.currentTimeMillis()
                    + (12 * 60 * 60 * 1000));

            CharSequence startTime = DateFormat.format(
                    "yyyy-MM-dd HH:mm:ss", startDate);

            CharSequence endTime = DateFormat.format("yyyy-MM-dd HH:mm:ss",
                    endDate);

            IsGreaterThanOrEqualTo restriction1 = new IsGreaterThanOrEqualTo(
                    AppointmentPropertyPath.START_TIME,
                    startTime.toString());
            IsLessThanOrEqualTo restriction2 = new IsLessThanOrEqualTo(
                    AppointmentPropertyPath.END_TIME, endTime.toString());
            And restriction3 = new And(restriction1, restriction2);

            FindItemResponse response = service.findItem(
                    StandardFolder.CALENDAR,
                    AppointmentPropertyPath.getAllPropertyPaths(),
                    restriction3);
            int numberOfItems = response.getItems().size();
            if (numberOfItems <= 0)
                Log.v(">>><<<<", "There are no Appointments..");
            for (int i = 0; i < numberOfItems; i++) {
                if (response.getItems().get(i) instanceof Appointment) {
                    Appointment appointment = (Appointment) response
                            .getItems().get(i);
                    String logicalRoomName = null, location = appointment
                            .getLocation();
                    Log.v(">>><<<<", "Location = " + location);
                    Log.v(">>><<<<",
                            "Subject = " + appointment.getSubject());
                    Log.v(">>><<<<",
                            "StartTime = " + appointment.getStartTime());
                    Log.v(">>><<<<",
                            "EndTime = " + appointment.getEndTime());
                    Log.v(">>><<<<",
                            "Body Preview = "
                                    + appointment.getBodyPlainText()); } }