camo has asked for the wisdom of the Perl Monks concerning the following question:

hi, i want to read from a imap-server the emails. The server is suse 9.1. i install the both modules Net::IMAP::Simple and Email::Simple. It is working good but now i habe to expansion my work. for this i must have the messageID from each email storing in the folder(INBOX). I think, this will not be possible but however i ask here: is it possible to becoming through Net::IMAP::Simple also the messageID. I dont mean the $msg or §message_number but the $messageID. Thanks if not which module i have to take, may be MAIL::ImapClient??

Replies are listed 'Best First'.
Re: How do i get the messagID - IMAP
by blahblahblah (Priest) on Jan 21, 2005 at 17:23 UTC
    If you mean the Message-Id header, you should be able to retrieve it like any other header. I use MAIL::IMAPClient in one of my scripts. Here's an example, taken from my code:
    # ($imap is a MAIL::IMAPClient object already connected to the server) $imap->Uid(0); $imap->select('INBOX'); $totalMessages = $imap->message_count(); for my $messageSequenceNumber (1 .. $totalMessages) { my @headerList = ('Message-ID', 'From', 'Subject', 'To', 'Date'); my $headers = $imap->parse_headers($readMessage, @headerList); print "Message-Id is --> $$headers{'Message-ID'}[0])"; }
    However, if you're already using other modules I'm sure you can get the value using them. Search the docs to see how to retrieve a specific header's value.
Re: How do i get the messagID - IMAP
by daddyefsacks (Pilgrim) on Jan 21, 2005 at 17:41 UTC
    The example from the Net::IMAP::Simple docs works fine to get the message id if you ask for the Message-ID header attribute:
    use Net::IMAP::Simple; use Email::Simple; my $server = Net::IMAP::Simple->new( 'someserver' ); $server->login( 'someuser', 'somepassword' ); my $nmessages = $server->select( 'somefolder' ); foreach my $msg ( 1 .. $number_of_messages ) { print "This message has been read before...\n" if $server->seen( $msg ); my $email = Email::Simple->new( join '', @{$server->get( $msg )} ) +; print $email->header('Message-ID'), "\n"; } $server->quit();