php-ews icon indicating copy to clipboard operation
php-ews copied to clipboard

Sending conference invitations with attachments is unsuccessful.

Open xblover opened this issue 7 years ago • 2 comments

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

xblover avatar Oct 29 '18 02:10 xblover

Are you getting an error message?

Garethp avatar Nov 01 '18 11:11 Garethp

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.

xblover avatar Nov 15 '18 02:11 xblover