OfficeDev / ews-java-api

A java client library to access Exchange web services. The API works against Office 365 Exchange Online as well as on premises Exchange.
MIT License
869 stars 560 forks source link

while adding resource for an appointment #698

Open kirit-s opened 5 years ago

kirit-s commented 5 years ago

when I'm trying to create an appointment using ews api and add resource using appointment.getResources().add(); method but the resource is not coming in attendee's calendar.

pkropachev commented 5 years ago

Looks like this is expected behaviour. I see the same behaviour in case of creating meeting using Outlook (Office 365).

Organizer adds room and resource during creation the meeting. Screenshot 2019-04-06 at 17 40 24 Organizer sees room and resource in the list of attendees (in Outlook and OWA). Screenshot 2019-04-06 at 17 44 37

But attendee sees only location. Screenshot 2019-04-06 at 17 41 10 Screenshot 2019-04-06 at 17 50 32 Screenshot 2019-04-06 at 17 57 47

I used EWS to retrieve the appointment (created using Outlook) for organizer and attendee.

void getAppointments() {
    try {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date startDate = formatter.parse("2019-04-06 00:00:00");
        Date endDate = formatter.parse("2019-04-06 23:59:59");

        CalendarView calendarView = new CalendarView(startDate, endDate);
        calendarView.setPropertySet(PropertySet.IdOnly);
        FindItemsResults<Appointment> result = service.findAppointments(WellKnownFolderName.Calendar, calendarView);

        for (Appointment item : result) {
            item.load(new PropertySet(
                    ItemSchema.Subject,
                    AppointmentSchema.Location,
                    AppointmentSchema.Resources,
                    AppointmentSchema.RequiredAttendees
            ));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

For organizer:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <h:ServerVersionInfo MajorBuildNumber="1771" MajorVersion="15" MinorBuildNumber="16" MinorVersion="20" Version="V2018_01_08" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
    </s:Header>
    <s:Body>
        <m:GetItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <m:ResponseMessages>
                <m:GetItemResponseMessage ResponseClass="Success">
                    <m:ResponseCode>NoError</m:ResponseCode>
                    <m:Items>
                        <t:CalendarItem>
                            <t:ItemId ChangeKey="DwAAABYAAAA5nqAMWqTJT4DTxhsm6DAfAADoV/f8" Id="AAMkADBmMzRjOTI4LWYxMTEtNGJhYy05ZDkyLTc0YTk3MGI2Yzg5NwBGAAAAAACrzafcGX0WQ7YvMTREYlVUBwA5nqAMWqTJT4DTxhsm6DAfAAAAAAENAAA5nqAMWqTJT4DTxhsm6DAfAADoYNZLAAA="/>
                            <t:Subject>Test1</t:Subject>
                            <t:Location>Room1; Resource1</t:Location>
                            <t:RequiredAttendees>
                                <t:Attendee>
                                    <t:Mailbox>
                                        <t:Name>User1</t:Name>
                                        <t:EmailAddress>user1@outlook.com</t:EmailAddress>
                                        <t:RoutingType>SMTP</t:RoutingType>
                                        <t:MailboxType>Mailbox</t:MailboxType>
                                    </t:Mailbox>
                                    <t:ResponseType>Unknown</t:ResponseType>
                                </t:Attendee>
                                <t:Attendee>
                                    <t:Mailbox>
                                        <t:Name>User2</t:Name>
                                        <t:EmailAddress>user2@outlook.com</t:EmailAddress>
                                        <t:RoutingType>SMTP</t:RoutingType>
                                        <t:MailboxType>Mailbox</t:MailboxType>
                                    </t:Mailbox>
                                    <t:ResponseType>Accept</t:ResponseType>
                                    <t:LastResponseTime>2019-04-06T14:44:19Z</t:LastResponseTime>
                                </t:Attendee>
                            </t:RequiredAttendees>
                            <t:Resources>
                                <t:Attendee>
                                    <t:Mailbox>
                                        <t:Name>Room1</t:Name>
                                        <t:EmailAddress>room1@outlook.com</t:EmailAddress>
                                        <t:RoutingType>SMTP</t:RoutingType>
                                        <t:MailboxType>Mailbox</t:MailboxType>
                                    </t:Mailbox>
                                    <t:ResponseType>Accept</t:ResponseType>
                                    <t:LastResponseTime>2019-04-06T14:35:42Z</t:LastResponseTime>
                                </t:Attendee>
                                <t:Attendee>
                                    <t:Mailbox>
                                        <t:Name>Resource1</t:Name>
                                        <t:EmailAddress>resource1@outlook.com</t:EmailAddress>
                                        <t:RoutingType>SMTP</t:RoutingType>
                                        <t:MailboxType>Mailbox</t:MailboxType>
                                    </t:Mailbox>
                                    <t:ResponseType>Accept</t:ResponseType>
                                    <t:LastResponseTime>2019-04-06T14:35:42Z</t:LastResponseTime>
                                </t:Attendee>
                            </t:Resources>
                        </t:CalendarItem>
                    </m:Items>
                </m:GetItemResponseMessage>
            </m:ResponseMessages>
        </m:GetItemResponse>
    </s:Body>
</s:Envelope>

For attendee:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <h:ServerVersionInfo MajorBuildNumber="1771" MajorVersion="15" MinorBuildNumber="19" MinorVersion="20" Version="V2018_01_08" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
    </s:Header>
    <s:Body>
        <m:GetItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <m:ResponseMessages>
                <m:GetItemResponseMessage ResponseClass="Success">
                    <m:ResponseCode>NoError</m:ResponseCode>
                    <m:Items>
                        <t:CalendarItem>
                            <t:ItemId ChangeKey="DwAAABYAAADJUd8lq1xXRISqo5G6s412AADoiL9y" Id="AAMkADIyNjk0OGM1LTc3ZGMtNGUwNS04NTUwLWM1Nzc1ZThmODAwOABGAAAAAACmTfXcTtS3T60jG+u0oH2xBwDJUd8lq1xXRISqo5G6s412AAAAAAENAADJUd8lq1xXRISqo5G6s412AADojTvAAAA="/>
                            <t:Subject>Test1</t:Subject>
                            <t:Location>Room1; Resource1</t:Location>
                            <t:RequiredAttendees>
                                <t:Attendee>
                                    <t:Mailbox>
                                        <t:Name>User1</t:Name>
                                        <t:EmailAddress>user1@outlook.com</t:EmailAddress>
                                        <t:RoutingType>SMTP</t:RoutingType>
                                        <t:MailboxType>Mailbox</t:MailboxType>
                                    </t:Mailbox>
                                    <t:ResponseType>Unknown</t:ResponseType>
                                </t:Attendee>
                                <t:Attendee>
                                    <t:Mailbox>
                                        <t:Name>User2</t:Name>
                                        <t:EmailAddress>user2@outlook.com</t:EmailAddress>
                                        <t:RoutingType>SMTP</t:RoutingType>
                                        <t:MailboxType>Mailbox</t:MailboxType>
                                    </t:Mailbox>
                                    <t:ResponseType>Accept</t:ResponseType>
                                    <t:LastResponseTime>0001-01-02T00:00:00Z</t:LastResponseTime>
                                </t:Attendee>
                            </t:RequiredAttendees>
                        </t:CalendarItem>
                    </m:Items>
                </m:GetItemResponseMessage>
            </m:ResponseMessages>
        </m:GetItemResponse>
    </s:Body>
</s:Envelope>
kirit-s commented 5 years ago

is there any other way to fetch resource of a particular event for attendees

pkropachev commented 5 years ago

As far as I know, no, there is no another way.

kirit-s commented 5 years ago

ok, thanks men...