In this tutorial i will tell you, how to read inbox folder mail from exchange server.In Earlie post Connect Exchange Server With PHP we have learn how to connect exchange server with PHP, so we will skip those steps.
So Now we have connected exchange server with PHP and going to download all emails and attachments.I am using ews-api
to connect Microsoft Exchange 2007 and 2010 Web Services in PHP.
You can also check other recommended tutorial of Exchange Api,
I am assuming you have $ews
object as mentioned in earlie post Connect Exchange Server With PHP.
Step 1: We will create request object to send api.The request object will have all setting or configuration properties that need to download all emails and attachments.
$request = new EWSType_FindItemType(); $itemProperties = new EWSType_ItemResponseShapeType(); $itemProperties->BaseShape = EWSType_DefaultShapeNamesType::ID_ONLY; $itemProperties->BodyType = EWSType_BodyTypeResponseType::BEST; $request->ItemShape = $itemProperties; $request->IndexedPageItemView = new EWSType_IndexedPageViewType(); $request->IndexedPageItemView->BasePoint = 'Beginning'; $request->IndexedPageItemView->Offset = 0; $request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType(); $request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType(); $request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::INBOX; $request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
Step 2: We will pass the above request object into the $ews
object.
try{ $result = $ews->FindItem($request); } catch(Exception $e) { echo $e->getMessage(); }
Now you will get all inbox emails in associative array.We have got all inbox emails and attachments using Microsoft Exchange server API with PHP.
This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More
in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More
This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More
We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More
in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More
I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More