Here is a hash I use:
my %ending_map = (
crt => ['application/x-x509-ca-cert' , 'base64'],
aiff => ['audio/x-aiff' , 'base64'],
gif => ['image/GIF' , 'base64'],
txt => ['text/plain' , '8bit'],
com => ['text/plain' , '8bit'],
class => ['application/octet-stream' , 'base64'],
htm => ['text/html' , '8bit'],
html => ['text/html' , '8bit'],
htmlx => ['text/html' , '8bit'],
htx => ['text/html' , '8bit'],
jpg => ['image/jpeg' , 'base64'],
dat => ['text/plain' , '8bit'],
hlp => ['text/plain' , '8bit'],
ps => ['application/postscript' , '8bit'],
'ps-z' => ['application/postscript' , 'base64'],
dvi => ['application/x-dvi' , 'base64'],
pdf => ['application/pdf' , 'base64'],
mcd => ['application/mathcad' , 'base64'],
mpeg => ['video/mpeg' , 'base64'],
mov => ['video/quicktime' , 'base64'],
exe => ['application/octet-stream' , 'base64'],
zip => ['application/zip' , 'base64'],
bck => ['application/VMSBACKUP' , 'base64'],
au => ['audio/basic' , 'base64'],
mid => ['audio/midi' , 'base64'],
midi => ['audio/midi' , 'base64'],
bleep => ['application/bleeper' , '8bit'],
wav => ['audio/x-wav' , 'base64'],
xbm => ['image/x-xbm' , '7bit'],
tar => ['application/tar' , 'base64'],
imagemap => ['application/imagemap' , '8bit'],
sit => ['application/x-stuffit' , 'base64'],
bin => ['application/x-macbase64'],
hqx => ['application/mac-binhex40' , 'base64'],
);
You can then access the specif parameter like this using the suffix of your file attachment as the hash key.:
$type = $ending_map{$suffix};
$mime->attach( Path => $att,
Filename => $file,
Type => $type->[0],
Encoding => $type->[1],
);
Hope this helps.
Trevor J. Joerges
(a.k.a. $SMACK)
http://members.home.net/tjoerges
--------------------------------------
$_=q;$TTnzyUUifyIIz!;;s;z;xdl;g;
y;x;b;;y;B-x;A-w;s;y;y; ;;print;
--------------------------------------
-----Original Message-----
From: Ron Grabowski [mailto:[EMAIL PROTECTED]]
Sent: January 17, 2001 12:21 PM
To: perllist
Subject: Re: MIME:Lite thing
> if ($suf eq 'gif') {
> $msg->attach(Type => 'image/gif',
> Path => "$s_dir/$nick/append/$at", Filename => $at);
> } elsif ($suf eq 'jpg') {
> $msg->attach(Type => 'image/jpeg',
> Path => "$s_dir/$nick/append/$at", Filename => $at);
> } elsif ($suf eq 'html') {
> $msg->attach(Type => 'text/html',
> Path => "$s_dir/$nick/append/$at", Filename => $at);
> } elsif ($suf eq 'htm') {
> $msg->attach(Type => 'text/html',
> Path => "$s_dir/$nick/append/$at", Filename => $at);
> } elsif ($suf eq 'txt') {
> $msg->attach(Type => 'text/plain',
> Path => "$s_dir/$nick/append/$at", Filename => $at);
> } else {
> $msg->attach(Type => 'APLICATION',
> Path => "$s_dir/$nick/append/$at", Filename => $at);
> }
I would put %h in a module and include a lot more file types ( someone
posted a listing of about 30 different MIME types a while back ).
my %h = ( jpg => 'text/html',
txt => 'text/plain' );
$msg->attach( Type => $h{$suf},
Path => "$s_dir/$nick/append/$at",
Filename => $at );
- Ron
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web
