Dearest Monks,
i have setup a gmail account to receive google alerts. i wrote the script below to dump the header and body of any email received by this account into a TXT file. my problem is this - when the body of the email is dumped into the TXT file i only get the resulting text and not the underlying HTML code. for example, what i want in the TXT file is:
<a href="http://www.blahblah.com/article.html">The Article Link</a>
Not:
The Article Link
my code is below. any thoughts? please note, the script below is only designed for capturing the header / body of a single email.
#!/usr/bin/perl -w
use strict;
use Mail::POP3Client;
my $user = 'blahblahblah';
my $pass = 'blahblahblah';
my $pop = new Mail::POP3Client(
USER => $user,
PASSWORD => $pass,
HOST => "pop.gmail.com",
PORT => 995,
USESSL => 'true',
);
my $count = $pop->Count();
if ($count < 0) {
print $pop->Message();
} elsif ($count == 0) {
print "no messages\n";
} else {
for my $i (1 .. $count) {
open(STDOUT, ">my_txt_output.txt");
my $fh = new IO::Handle();
$fh->fdopen( fileno( STDOUT ), "w" );
$pop->HeadAndBodyToFile( $fh, $i );
close STDOUT;
}
}
$pop->Close();
many thanks...
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.