5/20

The code, part 2

    my $folder = Email::Folder->new(shift);
    while (my $email = $folder->next_message()) {
	print $email->header("From");
	print "\n";
	my $doc = Plucene::Document->new();
	$doc->add(Plucene::Document::Field->Text(content => $email->as_string));
	add_field($doc, from    => $email->header("From"));
	add_field($doc, subject => $email->header("Subject"));
	add_field($doc, to      => $email->header("To"));
	add_field($doc, body    => $email->body);
	add_field($doc, message_id => $email->header("Message-Id"));
	$writer->add_document($doc);
    }
    undef $writer;