我已经使用 php-ews 一个月了,我可以开会,但我希望组织者是我参加会议的房间电子邮件/房间名称
例如,我在上午 8:00 - 上午 10:00 在房间 1 (room1@mydomain.com) 创建一个会议,我希望组织者是房间电子邮件 (room1@mydomain.com) / 房间名称 (room1)
我知道我可以在 Office 365 中执行此操作(使用我的凭据登录 -> 选择打开另一个邮箱 -> 选择 room1@mydomain.com),但我想通过 php-ews 执行此操作
我已经将资源邮箱、邮箱委托属性设置为我的登录凭据
是否可以将组织者名称更改为房间名称/房间电子邮件?
我的基本代码:
$host = $selected_exchange->exchange_host;
$username = $exchange_email;
$password = $exchange_password;
$version = $selected_exchange->exchange_version;
$timezone = 'SE Asia Standard Time';
$client = new Client($host, $username, $password, $version);
$client->setTimezone($timezone);
$start = new DateTime($booking_date . $booking_time_start . ":00");
$end = new DateTime($booking_date . $booking_time_end);
$guests = array(
array(
'name' => $room->exchange_room_name,
'email' => $room->exchange_room_email,
)
);
// Set connection information.
$request = new CreateItemType();
$request->SendMeetingInvitations = 'SendOnlyToAll';
//CalendarItemCreateOrDeleteOperationType::SEND_ONLY_TO_ALL;
$request->Items = new NonEmptyArrayOfAllItemsType();
// Build the event to be added.
$event = new CalendarItemType();
$event->RequiredAttendees = new NonEmptyArrayOfAttendeesType();
$event->Start = $start->format('c');
$event->End = $end->format('c');
$event->Subject = $meeting_title;
$event->Location = $room->exchange_room_name;
// Set the event body.
$event->Body = new BodyType();
$event->Body->_ = $special_request . " Meeting Created By: ";
$event->Body->BodyType = 'Text'; //BodyTypeType::TEXT;
// Iterate over the guests, adding each as an attendee to the request.
foreach ($guests as $guest) {
$attendee = new AttendeeType();
$attendee->Mailbox = new EmailAddressType();
$attendee->Mailbox->EmailAddress = $guest['email'];
$attendee->Mailbox->Name = $guest['name'];
$attendee->Mailbox->RoutingType = 'SMTP'; //RoutingType::SMTP;
$event->RequiredAttendees->Attendee[] = $attendee;
}
try
{
// Add the event to the request. You could add multiple events to create more
// than one in a single request.
$request->Items->CalendarItem[] = $event;
$response = $client->CreateItem($request);
// Iterate over the results, printing any error messages or event ids.
$response_messages = $response->ResponseMessages->CreateItemResponseMessage;
foreach ($response_messages as $response_message) {
// Make sure the request succeeded.
if ($response_message->ResponseClass != ResponseClassType::SUCCESS) {
$code = $response_message->ResponseCode;
$message = $response_message->MessageText;
//fwrite(STDERR, "Event failed to create with \"$code: $message\"\n");
$result = array('ok' => 0, 'message' => $message);
continue;
}
// Iterate over the created events, printing the id for each.
foreach ($response_message->Items->CalendarItem as $item) {
$id = $item->ItemId->Id;
//fwrite(STDOUT, "Created event $id\n");
$result = array('ok' => 1, 'message' => 'Success Added To Calendar');
}
}
}
catch(Exception $e)
{
$result = array('ok' => 0, 'message' => $message);
}