Below I have pasted some code that seems to work for setting the \Seen flag to a Cyrus IMAP store, however when looking at the store through mutt or Outlook the messages have not had the \Seen flag attached. Does anyone know why or see something I have wrong?
#!/usr/bin/perl #$Id$ # copied from cyrus_expunge.pl # given a date on the command line # select all messages in all folders before that date # set the \Seen flag on all selected messages # :!perl -d % -v three days ago # :!perl -d % -v yesterday midnight # :!perl -d % -v two hours ago # :!perl -d % -v '12/07/07' use Date::Manip; use Mail::IMAPClient; use IO::File; use Getopt::Std; # parse the command line our($opt_v, $opt_s) = (0, 0); getopts('sv') or die "usage: $0 [-vs]"; $opt_s = 1 if $opt_v; my $start = time; # parse the command-line date my $bdatestr = join(' ', @ARGV); my $bdate = ParseDate($bdatestr); my $bsecs = UnixDate($bdate, '%s'); # Change the following line (or replace it with something better): my($h, $u, $p) = ('imap.example.com', 'cyrus','secret'); my $imap = Mail::IMAPClient->new( Server => "$h", # imap host User => "$u", # $u, Password=> "$p", # $p, Uid => 1, # True value Port => 143, # Cyrus Debug => 0, # True value Buffer => 4096*10, # True value Fast_io => 1, # True value Timeout => 30, # True value Debug_fh=> IO::File->new('>/tmp/imap.out'), # f +handle ) or die "$@"; my $rfc2060date = $imap->Rfc2060_date($bsecs); our($folder, $nchanged) = ('', 0); our($nfolders, $nmessages, $ntotchanged) = (0, 0, 0); for my $f ( $imap->folders ) { $folder = $f; next unless $f =~ /user.user.sales/oi; $nfolders++; unless ($imap->select($f) ) { $imap->setacl($f, $u, 'lrswipcda') or warn "$0: Cannot setacl +for $f: $@\n" and next; $imap->select($f) or warn "$0: Cannot select $f: $@" and next; } my @msgs = $imap->before($rfc2060date); my $messages_before = $imap->message_count($f); if(defined($messages_before)) { $imap->see(@msgs) or warn "$0: cannot set \\Seen flag on messa +ges in folder '$f': $@"; $nchanged = scalar(@msgs); $ntotchanged += $nchanged; } write if $opt_v; } # write a summary if($opt_s) { my $stop = time; print "\nSummary:\n"; print "Elapsed Seconds: ", ($stop - $start), "\n"; print "Total Folders: $nfolders\n"; print "Total Messages: $nmessages\n"; print "Total Changed: $ntotchanged\n"; } format STDOUT = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>> $folder, $nchanged . format STDOUT_TOP = Folder Purged --------------------------------------------------------- ------ .

In reply to Mail::IMAPClient setting flags? by edwyr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.