Perl模块 - MIME :: Lite :: TT :: HTML,将HTML内容作为附件发送

时间:2011-10-19 15:01:18

标签: perl email mime

以下是我的Perl脚本的片段:

my %params = (
  sub_name            => $sub_name, 
  asm_name            => $asm_name,
  zsm                 => $zsm,
  store               => $store,
  pin                 => $pin,
  tier                => $tier,
  avg_weekly_all      => $avg_weekly_all,
  avg_weekly_br       => $avg_weekly_brakes,
  expected_sales      => $expected_sales,
  numOfBays           => $numOfBays,
  numOfTechs          => $numOfTechs,
  estimatedJobs       => $estimatedBrakeJobs,
  brand               => $brand,
  qty                 => $qty
);

my %options = (INCLUDE_PATH => '.');

my $msg = MIME::Lite::TT::HTML->new(
  From        => 'xxx.xxxx@somecompany.com',
  To          => 'me@somecompany.com',
  Subject     => "Request (MSG ID: $id)",
  Template    => { html => 'edge14.html.tt' },
  TmplOptions => \%options,
  TmplParams  => \%params
);

$msg->attr("content-type" => "multipart/mixed");

$msg->attach(
  Type => 'text/csv',
  Path => 'out.txt',
  Filename => "brake_lift_$id" . ".csv",
  Disposition => 'attachment'
);

$msg->send or die "Unable to send message: $!";

它正在发送电子邮件(带附件),但它不会在电子邮件正文中呈现html内容。它以纯文本形式发送并以“ATT00001..htm”格式附加html,是的,这是'htm'之前的两个点......

我做错了什么?

1 个答案:

答案 0 :(得分:1)

回答了我自己的问题!注意到所有其他哈希属性都是裸字,所以我把引号从“内容类型”中删除,它就像一个魅力!