[Rt-commit] r7242 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Wed Mar 14 09:45:21 EDT 2007


Author: ruz
Date: Wed Mar 14 09:45:20 2007
New Revision: 7242

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Attachment_Overlay.pm

Log:
 r4749 at cubic-pc:  cubic | 2007-03-14 16:38:47 +0300
 * add ContentAsMIME to Attachment class


Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Attachment_Overlay.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Attachment_Overlay.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Attachment_Overlay.pm	Wed Mar 14 09:45:20 2007
@@ -404,6 +404,27 @@
     return (\$body, $max);
 }
 
+=head2 ContentAsMIME
+
+Returns MIME entity built from this attachment.
+
+=cut
+
+sub ContentAsMIME {
+    my $self = shift;
+
+    my $entity = new MIME::Entity;
+    $entity->head->add( split /:/, $_, 2 )
+        foreach $self->SplitHeaders;
+
+    use MIME::Body;
+    $entity->bodyhandle(
+        MIME::Body::Scalar->new( $self->OriginalContent )
+    );
+
+    return $entity;
+}
+
 =head2 NiceHeaders
 
 Returns a multi-line string of the To, From, Cc, Date and Subject headers.


More information about the Rt-commit mailing list