I have task to read mails from secondary mail account from outlook using perl.
Asked
Active
Viewed 60 times
-4
-
1This question cannot be answered. You need to provide some example code. Then we can have a look and help you to implement multiple outlook accounts. – user3606329 Jan 31 '17 at 04:28
1 Answers
0
Please check the following it may help you.But you should install respective modules.Reference from "http://www.perlmonks.org/?node_id=916759"
use Modern::Perl;
use Mail::POP3Client;
use MIME::QuotedPrint;
my $pop_user = 'XXXXXXXXXX';
my $pop_pass = 'XXXXXXXXXX';
my $pop_host = 'exchange3';
#connect to POP3 sever
my $pop = new Mail::POP3Client ( HOST => $pop_host );
$pop->User($pop_user);
$pop->Pass($pop_pass);
$pop->Connect()
or die "Unable to connect to POP3 server: ".$pop->Message()."\n";
#count number of items in POP3 mailbox
my $mailcount = $pop->Count();
for (my $i = 1; $i <= $mailcount ; $i++) {
my $header = $pop->Head($i); #gets the header
my $uni = $pop->Uidl($i); # gets the unquie id
my $body = $pop->Body($i);
$body = decode_qp($body); #decode quoted printable body
say "$uni";
say "$header\n";
say "$body";
}
-
Thanks, But I am getting Unable to connect to POP3 server: could not connect socket [exchange3, 110]: Invalid argument error – iSampada Feb 02 '17 at 13:15
-
I feel may be it is due to invalid host name.Check with your hostname@iSampada – Feb 06 '17 at 08:27