3

I'm attempting to plug a php based calendar management system into exchange 2007 calendars.

I have the below code setup at present.

$subject = 'Appointment with ..';

        $request = new EWSType_CreateItemType();
        $request->Items = new EWSType_NonEmptyArrayOfAllItemsType();
        $request->Items->CalendarItem = new EWSType_CalendarItemType();

        $request->Items->CalendarItem->Subject = $subject;

        $date1 = new DateTime('2015-05-10T15:00:00+03:00');
        $DateStart = $date1->format('Y-m-d H:i:00');
        $date = new DateTime($DateStart);
        $request->Items->CalendarItem->Start = $date->format('c');
        $date1 = new DateTime('2015-05-10T17:00:00+03:00');
        $DateEnd = $date1->format('Y-m-d H:i:00');
        $date = new DateTime($DateEnd);
        $request->Items->CalendarItem->End = $date->format('c');

        $request->Items->CalendarItem->ReminderIsSet = false;

        $request->Items->CalendarItem->ReminderMinutesBeforeStart = 15;

        $request->Items->CalendarItem->Body = new EWSType_BodyType();
        $request->Items->CalendarItem->Body->BodyType = EWSType_BodyTypeType::HTML;

$request->Items->CalendarItem->Body->_ = <<<EOD

    <p><strong>Staff Attending</strong>:bob</p>

EOD;

        $request->Items->CalendarItem->ItemClass = new EWSType_ItemClassType();
        $request->Items->CalendarItem->ItemClass->_ = EWSType_ItemClassType::APPOINTMENT;

        $request->Items->CalendarItem->Sensitivity = new EWSType_SensitivityChoicesType();
        $request->Items->CalendarItem->Sensitivity->_ = EWSType_SensitivityChoicesType::NORMAL;

        $request->Items->CalendarItem->Categories = new EWSType_ArrayOfStringsType();
        $request->Items->CalendarItem->Categories->String = array(
            'Client Meeting (Scheduled)'
        );

        $request->Items->CalendarItem->Location = "Showroom";

        $request->SendMeetingInvitations = EWSType_CalendarItemCreateOrDeleteOperationType::SEND_ONLY_TO_ALL;
        $request->Items->CalendarItem->RequiredAttendees->Attendee[0]->Mailbox->EmailAddress = "user@domain.com";
        $request->Items->CalendarItem->RequiredAttendees->Attendee[0]->Mailbox->RoutingType  = 'SMTP';
        $n = 1;


        $response      = $ews->CreateItem($request);

This will setup an event in the users personal calendar just fine, but what I need to do is to get it to post to a public folder calendar which I have the folderID for.

If anyone could assist it would be greatly appreciated!

user1372212
  • 293
  • 1
  • 6
  • 21

2 Answers2

2

Try adding the line:

        $request->SavedItemFolderId->FolderId->Id=$folder_id;

after the $request = new EWSType_CreateItemType();

where $folder_id is your stupidly long microsoft folder id!!!!

Angus Walker
  • 378
  • 3
  • 13
  • I've tried putting that in and receive the following error on the line i insert the above, Creating default object from empty value – user1372212 May 13 '15 at 06:53
  • you could also try: $request->SavedItemFolderId->DistinguishedFolderId->Id = 'calendar'; $request->SavedItemFolderId->DistinguishedFolderId->Mailbox->EmailAddress = 'email@domain.com' using the email address of the folder (that's easy to set in exchange) – Angus Walker May 13 '15 at 16:21
1

I'm doing the same right now.

You have to replace the SEND_ONLY_TO_ALL with SEND_TO_NONE.

This means that we cannot send meeting invitations for appointments stored in a public folder (I've been trying to find a workaround for this problem for a couple weeks now).

I'm not sure if there are other problems in your request but this is surely an issue.

nowhere
  • 1,558
  • 1
  • 12
  • 31
  • More people had the same issue here: http://stackoverflow.com/questions/505978/invite-attendees-to-public-calendar-event-in-exchange-web-services – nowhere May 15 '15 at 12:40