先上最重要的干货
发送邮件正文及主题的时候一定要使用convert重新编码
主题:
utl_smtp.write_raw_data(l_mail_conn,
utl_raw.cast_to_raw(convert('Subject:' || p_subject || utl_tcp.crlf,
'ZHS16GBK')));
正文内容:
utl_smtp.write_raw_data(l_mail_conn,
utl_raw.cast_to_raw(convert(p_text_msg,
'ZHS16GBK')));
附件类型及头信息
utl_smtp.write_raw_data(l_mail_conn,
utl_raw.cast_to_raw(convert('Content-Type: ' || p_attach_mime || '; name="' ||
p_attach_name || '"' || utl_tcp.crlf,
'ZHS16GBK')));
附件名称
utl_smtp.write_raw_data(l_mail_conn,
utl_raw.cast_to_raw(convert('Content-Disposition: attachment; filename="' ||
p_attach_name || '"' || utl_tcp.crlf || utl_tcp.crlf,
'ZHS16GBK')));
附件路径:
l_file := convert(l_file,
'ZHS16GBK');
(顺便鄙视一下博客园,作为一个标榜为技术博客的园子,竟然对附件的支持这么弱,仅IE能下载,chrome和ff都不能下载。并且邮件链接地址还是我自己用F12获取的,不知道是不是我不会用。)
参考资料: