in reply to Re^7: mail attachment extraction
in thread mail attachment extraction

Thank you for giving this code, but there is something definitely weired... I pasted your code as it is and it always complain with "Need a message..." I use the same version of perl and Attachment::stripper as you...

Replies are listed 'Best First'.
Re^9: mail attachment extraction
by Krambambuli (Curate) on May 06, 2007 at 21:17 UTC
    Hmmmm... Are you sure you actually get a message out of your Inbox, so that $MsgTxt isn't empty ?

    Just insert
    print Dumper( $MsgTxt );
    where that assignment is and you should know. I've noticed you're always looking fo the newest unseen message - maybe you just have run out of 'amunition' and there is no more unseen message to cope with?

    Maybe it's better to search an message that you know for sure that exists and retrieve it during testing via uid, like
    my $MsgId = $imap->search('uid', '257283')->[0];


      What I get when I execute the script (the attachment is a text file, so it looks alright in $MsgTxt...):
      ****************** * MAIL EXTRACT * ****************** Connecting to IMAP server at 192.168.0.7:143... Use of uninitialized value in concatenation (.) or string at /home/jc/ +.eclipse/attachement_extract/mail_extract5.pl line 49. The size of the message is kB Continue ? Use of uninitialized value in concatenation (.) or string at /home/jc/ +.eclipse/attachement_extract/mail_extract5.pl line 58. $VAR1 = 'Return-Path: <test@mcm> X-Original-To: jc@mcm Delivered-To: jc@mcm Received: from [10.8.0.6] (unknown [10.8.0.6]) by debian (Postfix) with ESMTP id DD7F3E6B02 for <jc@mcm>; Wed, 2 May 2007 12:11:30 +0200 (CEST) Resent-From: test <test@localdomain> Resent-To: jc@mcm Resent-Date: Sun, 6 May 2007 17:01:45 +0200 Resent-Message-Id: <463DEDD9.2040003@localdomain> Resent-User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.10 +) Gecko/20060911 SUSE/1.5.0.10-1.1 Thunderbird/1.5.0.10 Resent-From: test <test@localdomain> Resent-To: jc@mcm Resent-Date: Sun, 6 May 2007 16:02:36 +0200 Resent-Message-Id: <463DDFFC.5050401@localdomain> Resent-User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.10 +) Gecko/20060911 SUSE/1.5.0.10-1.1 Thunderbird/1.5.0.10 Resent-From: test <test@localdomain> Resent-To: jc@mcm Resent-Date: Sun, 6 May 2007 15:21:56 +0200 Resent-Message-Id: <463DD674.4050109@localdomain> Resent-User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.10 +) Gecko/20060911 SUSE/1.5.0.10-1.1 Thunderbird/1.5.0.10 Message-ID: <463DD5F1.6080302@localdomain> Date: Sun, 06 May 2007 15:19:45 +0200 From: test <test@localdomain> User-Agent: Thunderbird 1.5.0.10 (X11/20060911) MIME-Version: 1.0 To: jc@mcm Subject: test X-Enigmail-Version: 0.94.2.0 Content-Type: multipart/mixed; boundary="------------060502080004010203030303" This is a multi-part message in MIME format. --------------060502080004010203030303 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit --------------060502080004010203030303 Content-Type: text/plain; name="text" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="text" texte fichier --------------060502080004010203030303-- '; Need a message at /home/jc/.eclipse/attachement_extract/mail_extract5. +pl line 64
        Well:
        ... Connecting to IMAP server at 192.168.0.7:143... Use of uninitialized value in concatenation (.) or string at /home/jc/ +.eclipse/attachement_extract/mail_extract5.pl line 49. The size of the message is kB Continue ?
        Seems you have an empty message there, since size is undef ? Check all the warnings you get, and correct the underlying problems before continuing. One step at time: check that you're message is ok, check that what you get is ok, insert print statements to assist you in debugging. Don't step forward to the next part of your program till you make sure that till that point everything is fine.