PHP code example of amirsanni / php-ews-wrapper

1. Go to this page and download the library: Download amirsanni/php-ews-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

amirsanni / php-ews-wrapper example snippets


composer 

$ews->contacts->limit = 10;

//Method takes an optional 'pageNumber' of type int
$res = $ews->contacts->get(); 

$ews->tasks->limit = 10;

//Method takes an optional 'pageNumber' of type int
$res = $ews->tasks->get();  

$ews->mail->limit = 30;

$draft_items = $ews->mail->draft();

if($draft_items->status === 1 && $draft_items->messages){
    foreach($draft_items->messages as $item){
        $ews->mail->send($item->message_id, $item->change_key);
    }
}


$ews->mail->limit = 30;

$items = $ews->mail->inbox();//$ews->mail->unread()

if($items->status === 1 && $items->messages){
    foreach($items->messages as $item){
        $ews->mail->markAsRead($item->message_id, $item->change_key);
        //$ews->mail->markAsUnread($item->message_id, $item->change_key);
    }
}


$ews->mail->limit = 30;

$items = $ews->mail->inbox();

if($items->status === 1 && $items->messages){
    foreach($items->messages as $item){
        $ews->mail->delete($item->message_id);
    }
}


$ews->events->event_start = '2019-06-27 08:00:00';
$ews->events->event_end = '2019-06-27 10:00:00';
$ews->events->timezone = 'Africa/Lagos';//Any PHP Timezone
$ews->events->location = 'Fabac, VI, Lagos';
$ews->events->subject = 'Test';
$ews->events->event_body = 'This is a test event';
$ews->events->invitees = [
    ['name'=>'John Doe', 'email'=>'[email protected]'],
    ['name'=>'Foo Bar', 'email'=>'[email protected]']
];

$res = $ews->events->create();