Thank you so much Eliya! I tried your code and it works great. You can pass a HoH to MIME::Lite::TT::HTML, I stand corrected :).
I thought I understood hash usage with TT2, but apparently I'm missing something. Could you possibly help me a bit more?
The data I wish to share in my email is queried from a DB:
$sth = $dbh -> prepare("SELECT * FROM bs_trans WHERE bsid = ?");
$sth -> execute($bsid);
I then generate my HoH using:
my $i = 0;
while (@rray3 = $sth -> fetchrow_array()) {
$item_hoh{$i} => {index => $i, mva => $rray3[3], hv1 => $rray3[5],
+ lv1 => $rray3[7], ltc => $rray3[10], qty => 'tbd'};
$i++;
};
I then prepare my email:
my $msg = MIME::Lite::TT::HTML -> new(
From => 'donotreply@blahblah.com',
To => $to,
Cc => $cc,
Subject => 'Bid Strategy System - Final Pricing Approval',
Template => {
html => 'email_bid_strategy_final_appr.tt',
},
TmplOptions => \%options,
TmplParams => \%item_hoh,
);
$msg -> send();
Notice that I'm passing the hash reference "\%item_hoh" to TT2 via TmplParams whereas you passed $HoH. I need to generate my HoH on the fly. While your code works for a hard coded HoH, mine doesn't and I don't understand why.
Again, in TT2, I'm attempting to display the results this way:
[% FOREACH record IN item_hoh.values.nsort('index') %]
<tr>
<td>[% record.index %]</td>
<td>[% record.mva %]</td>
<td>[% record.hv1 %]</td>
<td>[% record.hv2 %]</td>
<td>[% record.ltc %]</td>
<td>[% record.qty %]</td>
<tr>
[% END %]
None of the data is displayed in my emails when I use this code ... and I don't understand why. Thank you so much, I really appreciate your help, and I would be happy to buy you lunch because I'd really like to include this data in a table format in my emails :D.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.