[ic] Re: mime multipart & attachments

interchange-users@icdevgroup.org interchange-users@icdevgroup.org
Mon Oct 7 05:03:02 2002


Marco Mescoli writes: 

> If i put first "Plain text part" the received e-mail have right plain text
> but show a not extractable attachment.
> If i put first "Text file attach" the received e-mail show right attachment
> but the file content is duplicated in the mail message without "Plain text
> part".
> Someone has suggestions ? 
> 
> ==============================================
> [email_raw]
> from: m.mescoli@omnibit.nu
> to: m.mescoli@omnibit.nu
> subject: Mime
> [tag mime header][/tag] 
> 
> [comment]Plain text part[/comment]
> [tag mime Plain Text]Plain text content[/tag] 
> 
> [comment]Text file attach part [/comment]
> [tag
>   op=mime
>   type=text/plain
>   description=|
> Text file attachment
> Content-Disposition: attachment; filename="myfile.txt"|]
> [include file="tmp/myfile.txt"]
> [/tag]
> [tag mime boundary][/tag]
> [/email_raw]

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 

Ciao
     Racke 


-- 
Prolific Interchange Consulting (Excellent German Quality !).
Take a look at Materialboerse (http://www.materialboerse.de/), WITT
(http://www.witt-weiden.de/), Boxmover (http://shop.boxmover.ch/) or
Passionshop (http://www.passionshop.com/racke). Need a shop ? Contact us.