Page 1 of 1

imap_fetch_overview [SOLVED]

Posted: Thu Jan 05, 2006 9:11 pm
by dwessell
Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hey gang..

Ok... Moving forward 

I have a POP3 account that I'm trying to write some scripts for.. There's one message only in the account... I'm able to connect to the account just fine..

Using the code snippet below (Mostly from php.net)... I cannot get $val,$subj, or $val->subject to echo a value.. I'm assuming that it means nothing is being assigned.

$message works perfectly, so I'm taking that to mean that the message number is correct, since all the values are using $i to work through the mailbox.. Any thoghts would be welcome as always.

Thanks
david

Code: Select all

$MC=imap_check($mbox);
$MN=$MC->Nmsgs;
$overview=imap_fetch_overview($mbox,"1:$MN",0); 


$size=sizeof($overview);
for($i=1;$i<($size+1);$i++){
	$val=$overview[$i];
	$subj=$val->subject; 
	$message = imap_body($mbox,$i);
	echo "$val->subject   $message";
}

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Fri Jan 06, 2006 6:47 am
by dwessell
Solved ;)

The array that is returned begins at 0, the message UID's begin at 1..

Code: Select all

for($i=0;$i<$size;$i++){
	$val=$overview[$i];
	$subj=substr($val->subject,11); 
	$message = imap_body($mbox,$i+1);
	echo "$subj   $message";
}