note 42656 added to function.imap-fetchstructure

From: Date: Tue, 25 May 2004 16:12:43 +0000
Subject: note 42656 added to function.imap-fetchstructure
Groups: php.notes 
Request: Send a blank email to php-notes+get-70064@lists.php.net to get a copy of this message
This is my function to check attachments: <?php $est=imap_fetchstructure($con,$msg); if(checkAttachments($est)) { echo("You have attachment(s)"); } else { echo("You don't have attachment(s)"); } function checkAttachments($estMsg) { if(($estMsg->type!=0) && ($estMsg->type!=1)) { // Text and multipart parts will not be shown as attachments return(true); } else { // If there's no attachments, parts inside will be checked if($estMsg->parts) { $partMsg=$estMsg->parts; $i=0; // Parts will be checked while no attachments found or not all of them checked while(!(checkAttachments($partMsg[$i])) && ($i<sizeof($estMsg->parts))) { $i++; } // If any 'checkAttachment' calls returned 'true', 'i' should be // equal to number of parts(after increased in while). So, no // attachments found if($i==sizeof($estMsg->parts)) { return(false); } else { return(true); } } else { // If no parts and text or multipart type, no attachments return(false); } } } imap_close($con); ?> I hope this helps somebody else(if bugs, thanks for your fixes). ---- Manual Page -- http://www.php.net/manual/en/function.imap-fetchstructure.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42656 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42656&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42656&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70064) next »