Hello,

I'm using very simple script with MS Exchange server

"Inbox" is on the same level "test".

a)
When I point to my Inbox I see correct number of messages in $msgcount
However I do not see Subject my $subject = $imap->subject($i);

b)
When I use a rule to move message from Inbox to box test

c)
When I manually move messages from Inbox to box "test".
I see Subject without any problems

Any ideas why a) and b) does not work and I do not see Subject?? 

Thanks,

-Jiri-


use strict;
use Mail::IMAPClient;

my ( $host, $id, $pass, $folder );

# change to match your company's internal configuration
$host = "test";
$id   = "test";
$pass = "test";

#note the folders and the slashed
#$folder = 'Inbox/test'; # for a folder 2 deep from the main INBOX level
$folder = 'Inbox'; # for a folder 2 deep from the main INBOX level
#$folder = 'test'; # for a folder 2 deep from the main INBOX level


# INBOX -v
#       Parent -v
#              child
# also check the status bar on the top of Outlook to give you a hint for
# this entry

my $imap = Mail::IMAPClient->new(
                Server => $host,
                User    => $id,
                Password=> $pass,
                Clear   => 5   # Unnecessary since '5' is the default
#               ...             # Other key=>value pairs go here
)       or die "Cannot connect to $host as $id: $@";

$imap->select($folder) or die "Could not select: [EMAIL PROTECTED]"; # connect to the
folder 'INBOX/Parent/child'

# get a count of the messages that are present at the time the script is run
my $msgcount = $imap->message_count($folder);

# loop through the messages that were seen at the time the script was
started
# A while loop based on the message number could also work but at work the
process
# could continually generate messages and the while loop wouldn't stop till
the day's
# processing was done.

for ( my $i = 1; $i <= $msgcount; $i++ ) # there is no message 0
{
    my $data = $imap->message_string($i);
    #my $data = $imap->message_string(6);
    my @message = split /\n/, $imap->message_string($i);

    my $data1 = $imap->get_header($i);
 
    my $subject = $imap->subject($i);
    $imap->move('test') or die "Could not move: [EMAIL PROTECTED]";
    $imap->expunge; # needed to force Exchange to move/delete messages    
    
    if ( $subject eq "SPAM topic" )
    {
        $imap->delete_message($i) ;
        # could be improved on by creating an array of messages
        # and pass this method an array of message numbers
    }
    elsif ($subject eq "ArchiveTopic")
    {
        $imap->move('INBOX/Archive/May') or die "Could not move: [EMAIL PROTECTED]";
        $imap->expunge; # needed to force Exchange to move/delete messages
    }
    elsif ( $subject eq "NeedToParse" )
    {
        #my $string = $imap->message_string($msgid) or die "Could not
message_string: [EMAIL PROTECTED]";
        my $string = $imap->message_string ($msgcount) or die "Could not
message_string: [EMAIL PROTECTED]";        
        &ParseRoutine( $string );
    }
    else
    {
        # mark the message as UNREAD so that you can tell which messages
        # need to manually checke
        $imap->deny_seeing($i);
    }

}

# clean up after yourself
$imap->close or die "Could not close: [EMAIL PROTECTED]";

sleep (1);
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to