forked from jamesiarmes/php-ews
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
require_once "vendor/autoload.php"; | ||
|
||
use jamesiarmes\PEWS\API\Type; | ||
use jamesiarmes\PEWS\API\TypeTest; | ||
|
||
$api = new \jamesiarmes\PEWS\Mail\MailAPI(); | ||
$api->buildClient('server', 'username', 'password'); | ||
|
||
|
||
$mail = $api->getMailItems(); | ||
$mailItem = $mail[1]; | ||
|
||
//When the item is first returned from getMailItems(), it doesn't have attachment information filled out. You need to | ||
//get that mail item again directly | ||
$mailItem = $api->getItem($mailItem->getItemId()); | ||
|
||
//getFileAttachment() always returns an array of file attachments, or null | ||
$fileAttachment = $mailItem->getAttachments()->getFileAttachment()[0]; | ||
|
||
//Without this the content of the attachment is not returned, so we need to do another fetch to make sure we get the | ||
//content | ||
$attachment = $api->getAttachment($fileAttachment->getAttachmentId()); | ||
|
||
$name = $attachment->getName(); | ||
$contentType = $attachment->getContentType(); | ||
$content = $attachment->getContent(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters