Skip Menu |

This queue is for tickets about the Mail-IMAPClient CPAN distribution.

Report information
The Basics
Id: 48017
Status: open
Priority: 0/
Queue: Mail-IMAPClient

People
Owner: Nobody in particular
Requestors: schmitt [...] mmp.lu
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 3.19
Fixed in: (no value)



Thank you very much for your Mail::IMAPClient Perl module. In fact there is a functionality, which I think is missing. I would like to propose such a functionality for the next version of your module. Please correct me if I am wrong and this functionality exists already. I want to extract the single body parts of a message to handle them differently. Here is what exists $o_ImapBodyStruct = $o_ImapClient->get_bodystructure($l_MsgId); @l_BodyParts = $o_ImapBodyStruct->parts(); foreach my $l_BodyPart (@l_BodyParts) { $l_Message = $o_ImapClient->bodypart_string($l_MsgId, $l_BodyPart); print $l_Message; } In fact I am able to extract the content of each body part of the message. But I cannot see any possibility to get access to the header of a single body part. Only the header can tell me what to do with the content. Here is an example, how it could be handled. foreach my $l_BodyPart (@l_BodyParts) { # expand the access to header information by a body part index $l_Mime = $o_ImapBodyStruct->bodytype($l_BodyPart) . "/" . $o_ImapBodyStruct->bodysubtype($l_BodyPart); # adding the get_header method to the Mail::IMAPClient::BodyStructure class $l_Encoding = $o_ImapBodyStruct->get_header($l_BodyPart, "Content-Transfer-Encoding"); $l_ContentType = $o_ImapBodyStruct->get_header($l_BodyPart, "Content-Type"); $l_Message = $o_ImapClient->bodypart_string($l_MsgId, $l_BodyPart); if ($l_Mime eq 'text/plain') { print $l_Message; } elsif ($l_Mime eq 'image/gif') { # extract file name from $l_ContentType # extract attachment } ... } Thank you very much for considering this idea.
Not a bad idea. The Mail::IMAPClient interface is a bit "raw" for sure, so adding some code to make things like this easier is a good idea. Feel free to submit patches if you get a chance.