我可以用这种方式附加Excel文件的方式

时间:2014-08-05 07:25:25

标签: shell

以下是我给出的代码以及我在邮件中收到的excel附件已损坏

 #!/usr/bin/ksh
export MAILFROM="el@defiant.com" 
export MAILTO="youremail@gmail.com"
export SUBJECT="Test PDF for Email"
export BODY="/home/el/email_body.htm"
export ATTACH="/home/el/pdf-test.pdf"
export ATTACH1="/home/el/excel-test.xls"
export MAILPART=`uuidgen` ## Generates Unique ID
export MAILPART_BODY=`uuidgen` ## Generates Unique ID

(
 echo "From: $MAILFROM"
 echo "To: $MAILTO"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo "Content-Type: multipart/mixed; boundary=\"$MAILPART\""
 echo ""
 echo "--$MAILPART"
 echo "Content-Type: multipart/alternative; boundary=\"$MAILPART_BODY\""
 echo ""
 echo "--$MAILPART_BODY"
 echo "Content-Type: text/plain; charset=ISO-8859-1"
 echo "You need to enable HTML option for email"
 echo "--$MAILPART_BODY"
 echo "Content-Type: text/html; charset=ISO-8859-1"
 echo "Content-Disposition: inline"
 cat $BODY
 echo "--$MAILPART_BODY--"

 echo "--$MAILPART"
 echo 'Content-Type: application/pdf; name="'$(basename $ATTACH)'"'
 echo "Content-Transfer-Encoding: uuencode"
 echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'
 echo ""
 echo "--$MAILPART"
 echo 'Content-Type: application/msexcel; name="'$(basename $ATTACH1)'"'
 echo "Content-Transfer-Encoding: Base-64"
 echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH1)'"'
 echo ""
 uuencode $ATTACH $(basename $ATTACH) && uuencode $ATTACH1 $(basename $ATTACH1)
 echo "--$MAILPART--"
) | /usr/sbin/sendmail $MAILTO

请指导我关于excel的内容类型和内容编码类型,因为一旦我收到邮件文件,数据就会损坏。

0 个答案:

没有答案