php-ews
php-ews copied to clipboard
Sending conference invitations with attachments is unsuccessful.
Our project needs to implement a meeting invitation that can send attachments. I don't know too much about EWS. Below is the code I packaged. The code is written in the example/mail/sendMailWithAttachments.php file of php-ews. Also hope to be able to point to the maze.
`$client = wm_exchange_login();
if ( ! is_array($email))
{
return NULL;
}
$attendee = [];
foreach ($email as $k => $v)
{
$a = [];
$a['Mailbox'] = ['EmailAddress' => $v];
$attendee[] = $a;
}
$calendar_item = [];
$calendar_item['Start'] = (new DateTime($start_time))->format('c');
$calendar_item['End'] = (new DateTime($end_time))->format('c');
$calendar_item['Subject'] = $subject;
$calendar_item['Body'] = $content;
$calendar_item['IsAllDayEvent'] = FALSE;
$calendar_item['LegacyFreeBusyStatus'] = 'Busy';
$calendar_item['Location'] = $location;
$calendar_item['RequiredAttendees'] = ['Attendee' => $attendee];
$request = [];
$request['Items'] = ['CalendarItem' => $calendar_item];
$request['SendMeetingInvitations'] = Enumeration\CalendarItemCreateOrDeleteOperationType::SEND_TO_ALL_AND_SAVE_COPY;
$mailId = $client->sendMail($request, array('MessageDisposition' => 'SaveOnly'));
//Create our Attachments
$client->getClient()->CreateAttachment(array (
'ParentItemId' => $mailId->toArray(),
'Attachments' => array (
'FileAttachment' => array (
'Name' => 'picture.xls',
'Content' => 'https://share.weiyun.com/5hfgrhv'
)
),
));
$mailId = $client->getItem($mailId)->getItemId();
//Send the message
$response = $client->getClient()->SendItem(array (
'SaveItemToFolder' => true,
'ItemIds' => array (
'ItemId' => $mailId->toArray()
)
));
` Best Wishes! Xu Bo
Are you getting an error message?
Are you getting an error message?
Master, now I have another question.I wonder if this component supports calendar adding attachments? If support, please give some hints.