|  | 
  Terrye Hoffman - 2009-11-05 00:00:20I don't know if anybody is monitoring this discussion... 
This is such a great class, but some of the emails we get have an embedded jpg rather than text. For example, the person has embedded a picture of their newsletter rather than doing HTML. How can I make this jpg available? All that shows is something like this: 
 
<img width=770 height=995 
  src="cid:[email protected] " align=left 
  alt="a bunch of text">
 
Any suggestions?
 
Thanks, 
Terrye
  Terrye Hoffman - 2009-11-06 13:20:56 - In reply to message 1 from Terrye HoffmanI read some other posts and found a way to do it that works 98% of the time. Here's the code:
 $MessageRev contains the text of the email
 
 IF ( stristr($MessageRev, 'src="cid:') ) { // checks for any cid images
 $pattern = '/src="cid:(.*?)"/si';
 preg_match($pattern, $MessageRev, $out);
 $needswork = $out[0]; // this is the string with the cid image as the source
 
 $pattern2 = '/@(.*?)"/si';
 preg_match($pattern2, $needswork, $out2); // this is the part to remove
 
 $MessageRev = str_ireplace($out2[0],'"',$MessageRev);
 $MessageRev = str_ireplace('src="cid:','src="http://www.domainname.com/attachmentfolder/'.$MessageID,$MessageRev);	// this replaces the cid with the path to the saved attachment
 
 
  Terrye Hoffman - 2009-11-06 13:22:37 - In reply to message 2 from Terrye HoffmanI forgot the closing bracket in the code - here's the complete code:
 IF ( stristr($MessageRev, 'src="cid:') ) { // checks for any cid images
 $pattern = '/src="cid:(.*?)"/si';
 preg_match($pattern, $MessageRev, $out);
 $needswork = $out[0]; // this is the string with the cid image as the source
 
 $pattern2 = '/@(.*?)"/si';
 preg_match($pattern2, $needswork, $out2); // this is the part to remove
 
 $MessageRev = str_ireplace($out2[0],'"',$MessageRev);
 $MessageRev = str_ireplace('src="cid:','src="http://www.domainname.com/attachmentfolder/'.$MessageID,$MessageRev); // this replaces the cid with the path to the saved attachment
 }
 |