1

I'm creating calendar events in Exchange (2010) via EWS using the library PHP EWS.

When i create an event i set the start and end datetimes and the timezone. The XML that is sent looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages">
    <SOAP-ENV:Header>
        <ns1:RequestServerVersion Version="Exchange2010"/>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns2:CreateItem SendMeetingInvitations="SendToNone">
            <ns2:Items>
                <ns1:CalendarItem>
                    <ns1:ItemClass>IPM.Appointment</ns1:ItemClass>
                    <ns1:Subject>aa</ns1:Subject>
                    <ns1:Sensitivity>Normal</ns1:Sensitivity>
                    <ns1:Body BodyType="HTML">aa</ns1:Body>
                    <ns1:Categories>
                        <ns1:String>Afspraak</ns1:String>
                    </ns1:Categories>
                    <ns1:Importance>Normal</ns1:Importance>
                    <ns1:ReminderIsSet>false</ns1:ReminderIsSet>
                    <ns1:Start>2015-10-06T22:00:00</ns1:Start>
                    <ns1:End>2015-10-06T22:00:00</ns1:End>
                    <ns1:IsAllDayEvent>true</ns1:IsAllDayEvent>
                    <ns1:LegacyFreeBusyStatus>Free</ns1:LegacyFreeBusyStatus>
                    <ns1:StartTimeZone Id="W. Europe Standard Time">
                        <ns1:Periods>
                            <ns1:Period Bias="-PT1H" Name="Standard" Id="trule:Microsoft/Registry/W. Europe Standard Time/1-Standard"/>
                            <ns1:Period Bias="-PT2H" Name="Daylight" Id="trule:Microsoft/Registry/W. Europe Standard Time/1-Daylight"/>
                        </ns1:Periods>
                        <ns1:TransitionsGroups>
                            <ns1:TransitionsGroup Id="0">
                                <ns1:RecurringDayTransition>
                                    <ns1:To Kind="Period">trule:Microsoft/Registry/W. Europe Standard Time/1-Daylight</ns1:To>
                                    <ns1:TimeOffset>PT2H</ns1:TimeOffset>
                                    <ns1:Month>3</ns1:Month>
                                    <ns1:DayOfWeek>Sunday</ns1:DayOfWeek>
                                    <ns1:Occurrence>-1</ns1:Occurrence>
                                </ns1:RecurringDayTransition>
                                <ns1:RecurringDayTransition>
                                    <ns1:To Kind="Period">trule:Microsoft/Registry/W. Europe Standard Time/1-Standard</ns1:To>
                                    <ns1:TimeOffset>PT3H</ns1:TimeOffset>
                                    <ns1:Month>10</ns1:Month>
                                    <ns1:DayOfWeek>Sunday</ns1:DayOfWeek>
                                    <ns1:Occurrence>-1</ns1:Occurrence>
                                </ns1:RecurringDayTransition>
                            </ns1:TransitionsGroup>
                        </ns1:TransitionsGroups>
                        <ns1:Transitions>
                            <ns1:Transition>
                                <ns1:To Kind="Group">0</ns1:To>
                            </ns1:Transition>
                        </ns1:Transitions>
                    </ns1:StartTimeZone>
                    <ns1:EndTimeZone Id="W. Europe Standard Time">
                        <ns1:Periods>
                            <ns1:Period Bias="-PT1H" Name="Standard" Id="trule:Microsoft/Registry/W. Europe Standard Time/1-Standard"/>
                            <ns1:Period Bias="-PT2H" Name="Daylight" Id="trule:Microsoft/Registry/W. Europe Standard Time/1-Daylight"/>
                        </ns1:Periods>
                        <ns1:TransitionsGroups>
                            <ns1:TransitionsGroup Id="0">
                                <ns1:RecurringDayTransition>
                                    <ns1:To Kind="Period">trule:Microsoft/Registry/W. Europe Standard Time/1-Daylight</ns1:To>
                                    <ns1:TimeOffset>PT2H</ns1:TimeOffset>
                                    <ns1:Month>3</ns1:Month>
                                    <ns1:DayOfWeek>Sunday</ns1:DayOfWeek>
                                    <ns1:Occurrence>-1</ns1:Occurrence>
                                </ns1:RecurringDayTransition>
                                <ns1:RecurringDayTransition>
                                    <ns1:To Kind="Period">trule:Microsoft/Registry/W. Europe Standard Time/1-Standard</ns1:To>
                                    <ns1:TimeOffset>PT3H</ns1:TimeOffset>
                                    <ns1:Month>10</ns1:Month>
                                    <ns1:DayOfWeek>Sunday</ns1:DayOfWeek>
                                    <ns1:Occurrence>-1</ns1:Occurrence>
                                </ns1:RecurringDayTransition>
                            </ns1:TransitionsGroup>
                        </ns1:TransitionsGroups>
                        <ns1:Transitions>
                            <ns1:Transition>
                                <ns1:To Kind="Group">0</ns1:To>
                            </ns1:Transition>
                        </ns1:Transitions>
                    </ns1:EndTimeZone>
                </ns1:CalendarItem>
            </ns2:Items>
        </ns2:CreateItem>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

This works perfect. However, when i add attendees and change SendMeetingInvitations to SendOnlyToAll, for some reason, Exchange changes the date and time. The XML that is sent looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages">
    <SOAP-ENV:Header>
        <ns1:RequestServerVersion Version="Exchange2010"/>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns2:CreateItem SendMeetingInvitations="SendOnlyToAll">
            <ns2:Items>
                <ns1:CalendarItem>
                    <ns1:ItemClass>IPM.Appointment</ns1:ItemClass>
                    <ns1:Subject>aa</ns1:Subject>
                    <ns1:Sensitivity>Normal</ns1:Sensitivity>
                    <ns1:Body BodyType="HTML">aa</ns1:Body>
                    <ns1:Categories>
                        <ns1:String>Afspraak</ns1:String>
                    </ns1:Categories>
                    <ns1:Importance>Normal</ns1:Importance>
                    <ns1:ReminderIsSet>false</ns1:ReminderIsSet>
                    <ns1:Start>2015-10-06T22:00:00</ns1:Start>
                    <ns1:End>2015-10-06T22:00:00</ns1:End>
                    <ns1:IsAllDayEvent>true</ns1:IsAllDayEvent>
                    <ns1:LegacyFreeBusyStatus>Free</ns1:LegacyFreeBusyStatus>
                    <ns1:RequiredAttendees>
                        <ns1:Attendee>
                            <ns1:Mailbox>
                                <ns1:EmailAddress>some@email.com</ns1:EmailAddress>
                                <ns1:RoutingType>SMTP</ns1:RoutingType>
                            </ns1:Mailbox>
                        </ns1:Attendee>
                    </ns1:RequiredAttendees>
                    <ns1:StartTimeZone Id="W. Europe Standard Time">
                        <ns1:Periods>
                            <ns1:Period Bias="-PT1H" Name="Standard" Id="trule:Microsoft/Registry/W. Europe Standard Time/1-Standard"/>
                            <ns1:Period Bias="-PT2H" Name="Daylight" Id="trule:Microsoft/Registry/W. Europe Standard Time/1-Daylight"/>
                        </ns1:Periods>
                        <ns1:TransitionsGroups>
                            <ns1:TransitionsGroup Id="0">
                                <ns1:RecurringDayTransition>
                                    <ns1:To Kind="Period">trule:Microsoft/Registry/W. Europe Standard Time/1-Daylight</ns1:To>
                                    <ns1:TimeOffset>PT2H</ns1:TimeOffset>
                                    <ns1:Month>3</ns1:Month>
                                    <ns1:DayOfWeek>Sunday</ns1:DayOfWeek>
                                    <ns1:Occurrence>-1</ns1:Occurrence>
                                </ns1:RecurringDayTransition>
                                <ns1:RecurringDayTransition>
                                    <ns1:To Kind="Period">trule:Microsoft/Registry/W. Europe Standard Time/1-Standard</ns1:To>
                                    <ns1:TimeOffset>PT3H</ns1:TimeOffset>
                                    <ns1:Month>10</ns1:Month>
                                    <ns1:DayOfWeek>Sunday</ns1:DayOfWeek>
                                    <ns1:Occurrence>-1</ns1:Occurrence>
                                </ns1:RecurringDayTransition>
                            </ns1:TransitionsGroup>
                        </ns1:TransitionsGroups>
                        <ns1:Transitions>
                            <ns1:Transition>
                                <ns1:To Kind="Group">0</ns1:To>
                            </ns1:Transition>
                        </ns1:Transitions>
                    </ns1:StartTimeZone>
                    <ns1:EndTimeZone Id="W. Europe Standard Time">
                        <ns1:Periods>
                            <ns1:Period Bias="-PT1H" Name="Standard" Id="trule:Microsoft/Registry/W. Europe Standard Time/1-Standard"/>
                            <ns1:Period Bias="-PT2H" Name="Daylight" Id="trule:Microsoft/Registry/W. Europe Standard Time/1-Daylight"/>
                        </ns1:Periods>
                        <ns1:TransitionsGroups>
                            <ns1:TransitionsGroup Id="0">
                                <ns1:RecurringDayTransition>
                                    <ns1:To Kind="Period">trule:Microsoft/Registry/W. Europe Standard Time/1-Daylight</ns1:To>
                                    <ns1:TimeOffset>PT2H</ns1:TimeOffset>
                                    <ns1:Month>3</ns1:Month>
                                    <ns1:DayOfWeek>Sunday</ns1:DayOfWeek>
                                    <ns1:Occurrence>-1</ns1:Occurrence>
                                </ns1:RecurringDayTransition>
                                <ns1:RecurringDayTransition>
                                    <ns1:To Kind="Period">trule:Microsoft/Registry/W. Europe Standard Time/1-Standard</ns1:To>
                                    <ns1:TimeOffset>PT3H</ns1:TimeOffset>
                                    <ns1:Month>10</ns1:Month>
                                    <ns1:DayOfWeek>Sunday</ns1:DayOfWeek>
                                    <ns1:Occurrence>-1</ns1:Occurrence>
                                </ns1:RecurringDayTransition>
                            </ns1:TransitionsGroup>
                        </ns1:TransitionsGroups>
                        <ns1:Transitions>
                            <ns1:Transition>
                                <ns1:To Kind="Group">0</ns1:To>
                            </ns1:Transition>
                        </ns1:Transitions>
                    </ns1:EndTimeZone>
                </ns1:CalendarItem>
            </ns2:Items>
        </ns2:CreateItem>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

As you can see, the start and end datetime is the same in both situations, however when viewing the events in Outlook, they are different: event difference

(My Outlook has the timezone UTC+01:00)

One event is shown in the correct date/time, but the other somehow has a start date of 6-10-2015 02:00 and an end date of 8-10-2015 02:00.

Why is this? And more importantly how does one solve this issue?

Note: This only happens when IsAllDayEvent is true. If it is not an all day event it is created correctly.

RobinvdA
  • 1,313
  • 2
  • 13
  • 28
  • 1
    I remember encountering something similar where for some reason it submits the events in the wrong timezone. Here's another discussion on it https://social.msdn.microsoft.com/Forums/office/en-US/80c55a4a-64dd-455e-b56b-1f0317205f09/timezone-change-to-utc-while-creating-or-updating-the-appointment I solved this problem by sending the timezone as part of the SOAP Headers, as opposed to part of the XML payload. It's easy to do in my fork of php-ews, located here https://github.com/garethp/php-ews or see it manually https://github.com/Garethp/php-ews/blob/master/src/API/NTLMSoapClient.php#L134 – Gareth Parker Nov 17 '15 at 12:47

0 Answers0