Author |
|
bravedave Newbie
Joined: 05 September 2014 Location: Australia
Online Status: Offline Posts: 35
|
Posted: 25 May 2016 at 8:03pm | IP Logged
|
|
|
I want to be able to extract the binary data for an attachment - so I can save it - eg. pdf or image
using:
$oApiMailManager = CApi::Manager('mail');
if ( $oCollection = $oApiMailManager->getMessageList( $oAccount, $sFolder, $iOffset, $iLimit)) {
/* i have a collection of messages */
$collA = $oCollection->GetAsArray();
foreach ( $collA as $oMessage) {
/* i can do stuff */
$Uid = $oMessage->getUid();
/* etc */
$attachments = $oMessage->getAttachments()
but - how to I get to the attachment to save the file
foreach ( $attachments as $attachment) {
file_put_contents( 'c:\filename.jpg', $attachment->binarydata)
}
}
}
thanks in avance
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 26 May 2016 at 2:43am | IP Logged
|
|
|
PHP API doesn't support that directly, getAttachments() method only returns information about attachments, not the files themselves. You would need to use AJAX API for that, please see:
AJAX API - MessageGet
Hope this helps!
--
Regards,
Igor, AfterLogic Support
|
Back to Top |
|
|
bravedave Newbie
Joined: 05 September 2014 Location: Australia
Online Status: Offline Posts: 35
|
Posted: 26 May 2016 at 4:42am | IP Logged
|
|
|
Thanks for the reply
not quite what I was hoping for there
|
Back to Top |
|
|