PHP Classes

getting parts en attachments

Recommend this page to a friend!

      Lightning IMAP  >  All threads  >  getting parts en attachments  >  (Un) Subscribe thread alerts  
Subject:getting parts en attachments
Summary:attachments
Messages:2
Author:Harry Siereveld
Date:2015-03-26 11:56:16
 

  1. getting parts en attachments   Reply   Report abuse  
Picture of Harry Siereveld Harry Siereveld - 2015-03-26 11:56:17
Hi Tim,

very nice class.

I'm stuck on the attachment part.
How do I get a list (per message) of the attachments?

I'm keeping in mind that inline images (in the body) could be attachments too.
So:
- how do I get a list to figure out which attachment is and of what type
- how do I download that attachment to a specific folder

  2. Re: getting parts en attachments   Reply   Report abuse  
Picture of t withers t withers - 2015-03-26 18:43:53 - In reply to message 1 from Harry Siereveld
Been awhile since I have used this or worked on this, so I am going off what I gathered reading the docs.


What I would do is something like this:

foreach($messages as $message){
if($message->hasAttachments()){
foreach($message->attachments as $id=>$attachment){
echo $id."-".$attachment->data->parameters[0]->value;
}
}
}

To download an attachment, you would need to select the specific attachment and call download()

$message->attachments[$id]->download();

It should output the correct headers and spit out the file assuming no other content has been output yet.