PHP Classes

Retrieving the actual name of attached file.

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  Retrieving the actual name of...  >  (Un) Subscribe thread alerts  
Subject:Retrieving the actual name of...
Summary:I need the name of the file attached eg: attachment.gif
Messages:5
Author:yadnesh
Date:2008-03-05 04:00:21
Update:2008-03-17 06:31:29
 

  1. Retrieving the actual name of...   Reply   Report abuse  
Picture of yadnesh yadnesh - 2008-03-05 04:00:21
I just had a query. How do i retrieve the actual name of the attached file. I want to record the same in a database. Is it possible to do this. thanks in advance.

  2. Re: Retrieving the actual name of...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-03-05 06:57:57 - In reply to message 1 from yadnesh
If present in the message, it is returned in the FileName parameter.

  3. Another minor query!!   Reply   Report abuse  
Picture of yadnesh yadnesh - 2008-03-06 00:37:37 - In reply to message 2 from Manuel Lemos
One last question mate. I can see all the variables ie header subject etc, but cannot locate the actual "body" of the subject which I want to store. (I mean just the body part, no attachments, no subject). Which variable should I look for to just retrieve the body. Thanks again mate, ur a lifesaver!

  4. Re: Retrieving the actual name of...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-03-06 02:07:01 - In reply to message 3 from yadnesh
To retrieve the body, you must not pass the SkipBody parameter to the Decode function. If you use the SaveBody parameter, the body parts are saved to files instead of being returned as strings.

  5. Re: Retrieving the actual name of...   Reply   Report abuse  
Picture of yasir yasir - 2008-03-17 06:31:29 - In reply to message 1 from yadnesh

from the $results['Data'] which is raw data you can extract cid: like following...
preg_match_all("/cid:[a-zA-Z0-9@$\.-]+/",$results['Data'],$matches, PREG_PATTERN_ORDER);

foreach($matches[0] as $match){
print getfilenamefromcontentid($match,$results['Related']);
}

the function which can pass you file name can be found here..
function getfilenamefromcontentid($ContentID,$related){
foreach($related as $related)
{
if($related['ContentID']==substr($ContentID,4))
return $related['FileName'];
}
}