in reply to Re^3: Downloading IMAP Folders to mbox file
in thread Downloading IMAP Folders to mbox file

You have been a great help so far and the code you gave me is working like a charm. I am just having a real problem grasping the concept of how this module works. I have been sitting here for a few hours now trying to figure out the best way to delete (or mark for deletion) and then expunge all the messages in both folders that I am attempting to work with.
my $imap_client = Mail::IMAPClient->new( Server => 'imapserver.com:14 +3', User => 'uname', Password => 'pass') or die "IMAP Failure: $!"; foreach my $box qw( SPAM HAM ) { my $imap = $mgr->open( type => 'imap', imap_client => $imap_client, folder => "$box") or die "Couldn't create IMAP Client: $!\n"; open (MBOX, ">/home/mail/mbox/$box") or die "Couldn't create MBOX folder: $!\n"; close(MBOX); my $mbox = $mgr->open( type => 'mbox', folder => "/home/mail/mbox/$box", access => 'rw') or die "Couldn't open MBOX folder\n"; my @msgs = $imap->messages('ALL') or die "Couldn't get all messages\n"; $mgr->copyMessage($mbox,@msgs) or die "Couldn't copy messages\n"; # ... I know the msgs delete code goes here ... } $imap->logout();

Basically I know what needs to be done, but I just can't grasp how to do it. Thanks again for all the help thus far.

Eric

Replies are listed 'Best First'.
Re^5: Downloading IMAP Folders to mbox file
by sgifford (Prior) on Jun 18, 2006 at 22:11 UTC
    You could try the moveMessage method, which is supposed to copy and delete in one function call. Or you could try the delete method.
      I apologize, I should have been clearer with the with actual. I can't seem to get it to close the mailbox thereby expunging the messages. When I try to connect to the Exchange server using the builtin method of Mail::IMAP4, then I get an error saying "Can't use 'NTLM' as array ref in strict subs". Ok, no problem, I'll connect to the server via another perl module. I do and I can't open the imap folders 'rw' which means that when I close them, it won't let me WRITE my changes thus expunging the mail. (This script is killing me).

      Eric