Svenson's  Bulletin Board Forum Index Svenson's Bulletin Board
Bulletin Board for boat building and model airplane building enthusiasts.
 
AlbumAlbum   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Script to send attachment in email.

 
Post new topic   Reply to topic    Svenson's Bulletin Board Forum Index -> DB2
View previous topic :: View next topic  
Author Message
craig
Site Admin


Joined: 19 Feb 2006
Posts: 40

PostPosted: Thu May 25, 2006 8:02 am    Post subject: Script to send attachment in email. Reply with quote

TO="craigsvenson@freightliner.com"
SUBJECT="test of email encoding"

let R1=$RANDOM ; while [ $R1 -lt 10000 ] ; do let R1=$RANDOM ; done
let R2=$RANDOM ; while [ $R2 -lt 10000 ] ; do let R2=$RANDOM ; done
B1="----_=_NextPart_001.$R1.$R2"

{

FROM=$LOGNAME@$(hostname)
SUBJECT="Attachments From $FROM"
cat <<!
From: $FROM
To: $TO
Subject: $SUBJECT
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="$B1"

This is a multi-part message in MIME format.

--$B1
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

<html><head><title>$SUBJECT</title></head><body>
!

echo "<table border=1>"
# echo "<tr><th>Name</th><th>Size</th></tr>"
for f in $* ; do
ls -l $f | awk '{
printf("<tr><td>%s</td><td>%ld</td></tr>\n",$NF, $5)
}'
done
echo "</table>"

cat <<!
</body></html>

!


for f in $* ; do
FILENAME=$(basename $f)

cat <<!
--$B1
Content-Type: application/octet-stream; name="$FILENAME"
Content-Disposition: attachment; filename="$FILENAME"
Content-Transfer-Encoding: uuencode
Content-Description: "$FILENAME"
!

uuencode $f "$FILENAME"
done

echo "\n--$B1--\n"

} | /usr/sbin/sendmail -t
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Svenson's Bulletin Board Forum Index -> DB2 All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group