Search The ForumSearch   RegisterRegister  LoginLogin

AfterLogic WebMail Lite 7

 AfterLogic Forum : AfterLogic WebMail Lite 7
Subject Topic: API read attachments Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
apaame
Newbie
Newbie


Joined: 28 July 2016
Online Status: Offline
Posts: 1
Posted: 28 July 2016 at 12:03pm | IP Logged Quote apaame

Hi

Please advise how can I fetch the actual attachments for any message. I'm doing the following - I'm getting the attachment object, it's mime index, filename, size, etc but but the actual data. What method do I need to call to fetch the attachment data?

                              $oFrom = /* @var $oFrom \MailSo\Mime\EmailCollection */ $oMessage->getFrom();
                              echo "\t".htmlentities($oMessage->getUid().') '.$oMessage->getSubject().($oFrom ? ' ('.$oFrom->ToString().')' : ''))."\n";
                              $UID = $oMessage->getUid();
                              $iMessage = $oApiMailManager->getMessage($oAccount, $sFolder, (int) $UID, '', true, true, 600000);
                              $oAttachments = $iMessage->getAttachments();
                              if(is_object($oAttac hments)) {
                                 &n bsp; echo "Attachments:\r\n";
                                 &n bsp; $oAttachments->ForeachList(function ( $iAttachment) {
                                 &n bsp;      global $oApiMailManager;
                                 &n bsp;      global $oAccount;
                                 &n bsp;      global $sFolder;
                                 &n bsp;      global $UID;
                                       &n bsp; echo "\t".$iAttachment->getCid()."\t";
                                       &n bsp; echo $iAttachment->isInline()?"INLINE\r\n":"FILE".$iAttachment->getFileName()."\r\n";
                                 &n bsp;      $idx = $iAttachment->getMimeIndex();
                                 &n bsp; });



Thanks!
Back to Top View apaame's Profile Search for other posts by apaame
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6038
Posted: 28 July 2016 at 4:58pm | IP Logged Quote Igor

Currently it isn't possible to access attachments via PHP API, but it can be done via Web API. Please see:

Web API / Receiving mail / MessageGet

Once you get information about the message, it will contain Attachments item with hashes provided for each of the attachments, that's all you need to get attachments content. The documentation page shows how to build a link for retrieving a particular attachment item.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
MAlly
Newbie
Newbie
Avatar

Joined: 16 March 2017
Location: United States
Online Status: Offline
Posts: 11
Posted: 13 February 2018 at 9:39am | IP Logged Quote MAlly

Is it possible to use download link with AuthToken from provided example to create download link and and then use it to download attachment via cURL?
Back to Top View MAlly's Profile Search for other posts by MAlly
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6038
Posted: 13 February 2018 at 8:34pm | IP Logged Quote Igor

Yes sure, that should work with cURL just fine. You can find an example of uploading files with cURL here.

--
Regards,
Igor, Afterlogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide