Hi Theo, 

> Hrm.  FYI, there are assumptions made that the internal message structure is
> from the original message.  So while I don't think things will break, some
> rules may trigger inappropriately if you "blow their mind".

I'll try for a while.

> >     $part_array->[0]=3D"--$boundary";
> >     $part_array->[1]=3D"Content-Type: image/tiff;";
> >     $part_array->[2]=3D"Content-Transfer-Encoding: Base64";
> >     $part_array->[3]=3D"";
> Part data doesn't have mime boundaries and headers.  It's just the part
> content.  You would want to parse/shove this data into the object header.

OK, nor they are encoded anymore.

> >     open(FILE, "$dir/$tifffile") or die "$!";
> >     while (read(FILE, $buf, 60*57)) {
> >     $part_array->[$pline++]=3DMIME::Base64::encode_base64($buf);
> >     }
> Don't you have this from the message tree already?

No, this is a new image, extracted from the PDF part attached to the
message.

> >     $part_msg->header("content_type", "image/tiff");
> I think you'd want "content-type".

Of course :(

> >     push(@{$msg->{'parse_queue'}}, [ $part_msg, $boundary, $part_array, 1=
>  ]);
> >     $msg->add_body_part($part_msg);
> This doesn't make sense.  You either want to add the body part to
> the correct part of the tree, or setup the parse queue
> appropriately and let it do it.

This I borrowed from SpamAssassin code directly as there are very few
examples of add_body_part around. It's in Message.pm.

      # we've created a new node object, so add it to the queue along with the
      # text that belongs to that part, then add the new part to the current
      # node to create the tree.
      push(@{$self->{'parse_queue'}}, [ $part_msg, $p_boundary, $part_array, $su
bparse ]);
      $msg->add_body_part($part_msg);

I could not find any proper way to associate the body of the part in
$part_array with the node defined in part_msg: there is the method
header to add /modify a header of a part, but no similar (documented)
method to add/modify the body of the part.

Best regards,

Olivier

Reply via email to