Hello I have a PHP IMAP functions which extract the attachments of a specific body of an email, I found out this article : http://www.linuxscope.net/articles/mailAttachmentsPHP.html but it shows an error : Warning: imap_bodystruct() [function.imap-bodystruct]: Bad message number I dont know what I am missing. Here is my code
session_start();
include('settings.php');
include('vars.php');
$struct = imap_fetchstructure($mbox,$getmsgid, FT_UID);
$contentParts = count($struct->parts);
if ( $contentParts >= 2 ) {
for ( $ii=2; $ii<=$contentParts; $ii++ ) {
$att[$ii-2] = imap_bodystruct($mbox,$getmsgid, $ii);
echo $ii . '<br />';
}
for ($k=0;$k<sizeof($att);$k++) {
if ($att[$k]->parameters[0]->value == "us-ascii" || $att[$k]->parameters[0]->value == "US-ASCII") {
if ($att[$k]->parameters[1]->value != "") {
$selectBoxDisplay[$k] = $att[$k]->parameters[1]->value;
}
}elseif ($att[$k]->parameters[0]->value != "iso-8859-1" && $att[$k]->parameters[0]->value != "ISO-8859-1") {
$selectBoxDisplay[$k] = $att[$k]->parameters[0]->value;
}
}
}
if (sizeof($selectBoxDisplay) > 0) {
echo "<select name=\"attachments\" size=\"3\" class=\"tblContent\" onChange=\"handleFile(this.value)\" style=\"width:170;\">";
for ($j=0;$j<sizeof($selectBoxDisplay);$j++) {
echo "\n<option value=\"$j\">". $selectBoxDisplay[$j] ."</option>";
}
echo "</select>";
}
the settings.php contains my $mbox connection it works fine, the only problem here is the imap_bodystruct($mbox,$getmsgid, $ii); is there any problem with my syntax there?
Thanks you,