场景:数据库里有个blob字段存着上传过来的excel文件,下载要通过发送邮件的方式把excel发送出去。
mail.addFileAffix("excel.xls",byte[]);
添加附件方法如下
public void addFileAffix(String fileName,byte[] b)
throws MailException {
try {
BodyPart bp = new MimeBodyPart();
bp.setDataHandler(new DataHandler(new ByteArrayDataSource( b, "application/octet-stream")));
bp.setFileName(fileName );
mp.addBodyPart(bp);
}
catch (Exception e) {
throw new MailException("Add attachment fail");
}
}
--------------------------------------------
现在的问题是,收到的邮件用office打开时提示格式错误,点击确定后打开的内容全部乱码,面目全非,英文都乱成看不懂的特殊符号
?? à?±á>?? ????????_???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? f2???á°??\p zhurenjun B°a?=? ??= <[8X@?"
? à +?? ?? à
·?1????Arial1 ?????[SO1 ?????[SO1 ?????[SO1 ?????[SO1 ?????[SO1 ?6????[SO1 ?>????[SO1????Arial1 ????Verdana1 ??????[SO1 ????Verdana1 ?????[SO1*????
HP Simplified1 ?Q????[SO1 ?Q????[SO1 ??????[SO1 h6????[SO1 ,6????[SO1 6????[SO1 ? ????[SO1 ? ????[SO1 ?<????[SO1 ??????[SO1 ?4????[SO1 ?4????[SO1 ? ????[SO1 ?
????[SO1 ?????[SO1 ?????[SO1 ? ????[SO "?"#,##0;"?"\-#,##0 "?"#,##0;[Red]"?"\-#,##0 "?"#,##0.00;"?"\-#,##0.00 # "?"#,##0.00;[Red]"?"\-#,##0.00 7*2_ "?"* #,##0_ ;_ "?"* \-#,##0_ ;_ "?"* "-"_ ;_ @_ .))_ * #,##0_ ;_ * \-#,##0_ ;_ * "-"_ ;_ @_ ?,:_ "?"* #,##0.00_ ;_ "?"* \-#,##0.00_ ;_ "?"* "-"??_ ;_ @_ 6+1_ * #,##0.00_ ;_ * \-#,##0.00_ ;_ * "-"??_ ;_ @_ \$#,##0_);\(\$#,##0\) -\$#,##0_);[Red]\(\$#,##0\) \$#,##0.00_);\(\$#,##0.00\) % \$#,##0.00_);[Red]\(\$#,##0.00\)à ?? ? à ??? à ??? à ??? à ??? à ??? à ??? à ??? à ??? à ??? à ??? à ??? à ??? à ??? à ??? à ? à ???? à ???? à ???? à ???? à ???? à ???? à ???? à ???? à ???? à ???? à ???? à ???? à ¬???? à ¬???? à ¬???? à ¬???? à ¬???± à ¬???? à
?? ? à ?? ?? à ???? à ???P?? à ???P? à ??? ? à ???? à ???? à ???? à ???a±? à ,???? à *???? à ??? ?
?
? à ???ff?¬?¬· à ???? à ???? à ???
x @ @ à
x @ @ ? à
x @ @ ? à x @ @ 2 à x @ @ 2 à x @ @ 3 à x @ @ 3 à 1*|? à 1 L? à 1( ? à 1 L? à 1 ? à 1 L à 1(\ à 1 L à 1 L à
!x à 1(| à ?? à 1 ? à ? à @? à 1(|? à 1 ? à 1 H à 1"|? | |YG??}-}#
.00)_ *
}-}"
.00)_ *
}(}B ??P?.00)_ *}(}C ??P?.00)_ *}(}D ???.00)_ *}(}E ???.00)_ *}-}F
??v?.00)_ *
}-}G
.00)_ *
}-}H
.00)_ *
}-}I
.00)_ *
}-}J
.00)_ *
}A}K
.00)_ *
??;_ @_ }A}L
.00)_ *
??;_ @_ }A}M
.00)_ *
??;_ @_ }(}N ??.00)_ *}(}O ??.00)_ *}A}P
.00)_ *
??;_ @_ }-}Q
.00)_ *
}-}R
.00)_ *
}-}U
??v?.00)_ *
}-}V
.00)_ *
}A}W
.00)_ *
??;_ @_ }-}X