Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.