[ic] Mime attachment: tested solution

Marco Mescoli interchange-users@icdevgroup.org
Fri Oct 11 04:10:02 2002


> You might consider to use my email_mime.tag:
> UserTag email_mime Order to subject reply from extra type path btype
> UserTag email_mime hasEndTag
> UserTag email_mime Interpolate
> UserTag email_mime Routine <<EOR
> sub {
>   require MIME::Lite;
>
>   my($to, $subject, $reply, $from, $extra, $type, $path, $btype, $body) =
@_;
>   my($ok, @types, @paths);
>   my($msg);
>
>   $subject = '<no subject>' unless defined $subject && $subject;
>
>   $reply = '' unless defined $reply;
>   $reply = "Reply-to: $reply\n" if $reply;
>   if (! $from) {
>   $from = $Vend::Cfg->{MailOrderTo};
>   $from =~ s/,.*//;
>   }
>
>   $extra =~ s/\s*$/\n/ if $extra;
>   $ok = 0;
>
>   $msg = MIME::Lite -> new (From => $from, To => $to, Subject => $subject,
Type => ($btype || 'TEXT'), Data => $body);
>
>   if (ref $type eq 'ARRAY') {
>     @types = @{$type};
>   } else {
>     @types = $type;
>   }
>
>   if (ref $path eq 'ARRAY') {
>     @paths = @{$path};
>   } else {
>     @paths = $path;
>   }
>
>   for (my $i = 0; $i < @types; $i++) {
>     $msg -> attach (Type => $types[$i], Path => $paths[$i]);
>   }
>
>   $ok = $msg -> send;
>
>   if (!$ok) {
>     logError("Unable to send mail using $Vend::Cfg->{'SendMailProgram'}\n"
.
>     "To '$to'\n" .
>     "From '$from'\n" .
>     "With extra headers '$extra'\n" .
>     "With reply-to '$reply'\n" .
>     "With subject '$subject'\n" .
>     "And body:\n$body");
>   }
>   $ok;
> }
> EOR
>

Thanks for your email_mime tag Racke.
Great ... all run as i need.

I have copied email_mime in the main interchange usertag dir.
This is the code that i have used for [email_mime] tag.

[email_mime
  to="m.mescoli@omnibit.nu"
  subject="Test mime"
  reply="m.mescoli@omnibit.nu"
  from="m.mescoli@omnibit.nu"
  extra=""
  type="image/jpeg"
  path="tmp/image.jpg"
  btype="text/plain"] Test tag email_mime [/email_mime]

----------------------------------
Salutoni
            Marco