-1

I'm trying to write a script, that transfers internal office mails to my normal mail-account. The only way I see to identify unread mails is, that they are in a <tr> with a special style ('bold preview'). I'm able to store the <tr>-element in a HTML-Element, a dump() gives me:

<tr class="bold preview"> @0.1.0.2.0.0.0.0.2.0.4.3.1.3
<td class="collapsing" style="padding-top: .4em; padding-bottom: .4em;" 
valign="top"> @0.1.0.2.0.0.0.0.2.0.4.3.1.3.0
<input class="pk-check-select" name="pk_in_del[145930]" 
onchange="checked_pk(this)" type="checkbox" value="1" /> 
@0.1.0.2.0.0.0.0.2.0.4.3.1.3.0.0
<td style="padding-top: .4em; padding-bottom: .4em;" valign="top"> 
@0.1.0.2.0.0.0.0.2.0.4.3.1.3.1
" M. S. "
<td style="padding-top: .4em; padding-bottom: .4em;" valign="top"> 
@0.1.0.2.0.0.0.0.2.0.4.3.1.3.2
<a class="pk-subject-line"  href="../index.php&
csrf=1ff5569125fc9b41427d5816e5ba52912738e40a12df58f053f3c9886c7989dc
&amp;nav_mode=r&amp;std_nav_id=4&amp;pk_mode=in_view&amp;PK_ID=145930" 
title="Messaging-Dienste "> @0.1.0.2.0.0.0.0.2.0.4.3.1.3.2.0
" Messaging-Dienste "
<span class="preview"> @0.1.0.2.0.0.0.0.2.0.4.3.1.3.2.0.1
" &dash;  Werte Kolleginnen und Kollegen, hier eine Zusammenfassun..."
" "
<td class="right aligned" style="padding-top: .4em; padding-bottom: .4em;" 
valign="top"> @0.1.0.2.0.0.0.0.2.0.4.3.1.3.3
" 10.12.2018 - 15:52 " 

now I have no idea how to follow this single link to retrieve the whole message. The number and the content of the link varies everytime, the page is called.

  • Welcome to Stack Overflow and the Perl tag. Please read [ask] and take the [tour], then take a look at [mcve]. We will need to see a larger sample of this page, with at least two rows of relevant mail. You'll also need to tell us what it is you want to do exactly. If you want to click the subject link, you can find all links with `/pk_mode=in_view/` in them for example, and follow each of them. Please keep in mind that forwarding (is that what you mean) company email to your private email address might be a breach of your work contract in Germany. – simbabque Dec 12 '18 at 19:22

1 Answers1

1

Sorry, I found it myself, it's

# get all the table rows
my @list2 = $mech->look_down('_tag' => 'tr',
                            'class' => 'bold preview');
# only the first is of interest
if(!defined $list2[0]){exit 0;}
# get all the links, only the first matters
my @linklist= $list2[0]->look_down(_tag => 'a');
# follow the link
$mech->get($linklist[0]->attr('href'));