Jump to content

need help with email attachments.....


meomike2000

Recommended Posts

mike without knowing exactly what code you have, there isn't much anyone can suggest.

 

how are you accessing the emails in the first place, I would imagine that whatever method you are using would have a way to access email properties including attachments, sorry not a great reply but you haven't given more than a vague description to respond to.

i use this sample:

 

      $structure = imap_fetchstructure($this->mail,$this->messId);
	if (!$structure->parts) {  // not multipart
		$body = $this->getPart($s,0);
	}else {  // multipart: iterate through each part
		$plainmsg = false;
		$htmlmsg = false;
		$attachment = Array();
		foreach ($structure->parts as $partno0 => $p) {				
$piece = $this->getPart($p,$partno0+1);
if ($piece['type'] == 'attachment') {
	$attachment[] = $piece['fileName'];
				//$body['attachment'] = $piece['fileName'];//$this->getPart($p,$partno0+1);
			}else{					
				if ($piece['type'] == 'plain') {
					$plainmsg = $this->formatMessage($piece['body']);
				}
				if ($piece['type'] == 'html') {
					$htmlmsg = $this->formatMessage($piece['body']);
				}
			}
		}
if ($attachment) {$body['attachment'] = $attachment;}
		if ($plainmsg && $htmlmsg) {
			$body['body'] = ($this->userChoice == 'html') ? $htmlmsg : $plainmsg;
			//$body['body'] = $piece['type'];
		}else{
			$body['body'] = ($htmlmsg) ? $htmlmsg : $plainmsg;
			//$data = ($partno > 0) ? imap_fetchbody($mbox,$mid,$partno) : imap_body($mbox,$mid);
		}
	}

 

and the piece from  $this->getPart($p,$partno0+1); that handles attachment......

 

// ATTACHMENT
	// Any part with a filename is an attachment,
	// so an attached text file (type 0) is not mistaken as the message.
if ($params['filename'] || $params['name']) {
		// filename may be given as 'Filename' or 'Name' or both
$filename = ($params['filename'] || $params['name']) ? $params['filename'] : $params['name'];
        $body['type'] = 'attachment';//$data;
$body['fileName'] = $filename;
$body['fileData'] = $data;
	}

 

hope this helps

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.