Php

How to Read inbox Mails From Exchange Server

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.

Related Post

How To Download inbox Mails and Attachments From Exchange Server

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.

Recent Posts

Configure and Retrieve S3 Information Using Laravel PHP-AWS-SDK

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

2 months ago

What is the Purpose of php_eol in PHP?

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

8 months ago

Laravel Table Relationship Methods With Example

This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More

8 months ago

Exploring the Power of Laravel Eloquent Join?

We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More

9 months ago

Quick and Easy Installation of Laravel Valet

in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More

9 months ago

What is Laravel Soft Delete and How Does it Work?

I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More

9 months ago

Categories