function GetPart($msg_number, $mime_type, $structure = false, $part_number = false) 
	{
		$stream = $this->mbox;
		$prefix = "";

		$structure = $structure ? $structure : imap_fetchstructure($stream, $msg_number);
		
		if ($structure) 
		{
			if ($mime_type == $this->GetMimeType($structure)) 
			{
				$part_number = $part_number ? $part_number : "1";
				$text = imap_fetchbody($stream, $msg_number, $part_number);
				
				if ($structure->encoding == 3) 
				{
					return imap_base64($text);
				} 
				else if ($structure->encoding == 4) 
				{
					return imap_qprint($text);
				} 
				else 
				{
					return $text;
				}
			}

			if ($structure->type == 1) /* multipart */ 
			{
				while(list($index, $sub_structure) = each($structure->parts)) 
				{
					if($part_number) 
					{
						$prefix = $part_number . '.';
					}
					$data = $this->GetPart($msg_number, $mime_type, $sub_structure,$prefix .    ($index + 1));
					
					if($data) 
					{
						return $data;
					}
				}
			}
			
		}
		
		// no structure returned
		return false;
	}
function GetPart($msg_number, $mime_type, $structure = false, $part_number = false) 
	{
		$stream = $this->mbox;
		$prefix = "";

		$structure = $structure ? $structure : imap_fetchstructure($stream, $msg_number);
		
		if ($structure) 
		{
			if ($mime_type == $this->GetMimeType($structure)) 
			{
				$part_number = $part_number ? $part_number : "1";
				$text = imap_fetchbody($stream, $msg_number, $part_number);
				
				if ($structure->encoding == 3) 
				{
					return imap_base64($text);
				} 
				else if ($structure->encoding == 4) 
				{
					return imap_qprint($text);
				} 
				else 
				{
					return $text;
				}
			}

			if ($structure->type == 1) /* multipart */ 
			{
				while(list($index, $sub_structure) = each($structure->parts)) 
				{
					if($part_number) 
					{
						$prefix = $part_number . '.';
					}
					$data = $this->GetPart($msg_number, $mime_type, $sub_structure,$prefix .    ($index + 1));
					
					if($data) 
					{
						return $data;
					}
				}
			}
			
		}
		
		// no structure returned
		return false;
	}
function GetPart ( $ msg_number , $ mime_type , $ structure = false , $ part_number = false ) { $ stream = $ this -> mbox ; $ prefix = "" ; $ structure = $ structure ? $ structure : imap_fetchstructure ( $ stream , $ msg_number ) ; if ( $ structure ) { if ( $ mime_type == $ this -> GetMimeType ( $ structure ) ) { $ part_number = $ part_number ? $ part_number : "1" ; $ text = imap_fetchbody ( $ stream , $ msg_number , $ part_number ) ; if ( $ structure -> encoding == 3 ) { return imap_base64 ( $ text ) ; } else if ( $ structure -> encoding == 4 ) { return imap_qprint ( $ text ) ; } else { return $ text ; } } if ( $ structure -> type == 1 ) /* multipart */ { while ( list ( $ index , $ sub_structure ) = each ( $ structure -> parts ) ) { if ( $ part_number ) { $ prefix = $ part_number . '.' ; } $ data = $ this -> GetPart ( $ msg_number , $ mime_type , $ sub_structure , $ prefix . ( $ index + 1 ) ) ; if ( $ data ) { return $ data ; } } } } // no structure returned
 return false ; }
Returns a single part of a message

@param int $msg_number The message number in the mailbox
@param string $mime_type The mime type of the part to retrieve
@param object $structure The message structure
@param int $part_number The id of the part number within the message
@return object The message part, or false if no match exists
Returns a single part of a message