CREATE OR REPLACE PROCEDURE SEND_KIML(
SENDER_ADDRESS IN VARCHAR2,
RECEIVER_ADDRESS IN VARCHAR2,
SUBJECT IN VARCHAR2,
CONTENTS IN VARCHAR2
) IS
EMAIL_SERVER VARCHAR2(30) := '10.240.0.6';
PORT NUMBER := 25;
CONN UTL_SMTP.CONNECTION;
MESG VARCHAR2(4000);
BEGIN
CONN:= UTL_SMTP.OPEN_CONNECTION(EMAIL_SERVER,PORT);
UTL_SMTP.HELO(CONN,EMAIL_SERVER);
UTL_SMTP.MAIL(CONN,SENDER_ADDRESS);
UTL_SMTP.RCPT(CONN,RECEIVER_ADDRESS);
MESG:= 'CONTENT-TYPE: TEXT/PLAIN; CHARSET=utf-8' || UTL_TCP.CRLF ||
'DATE:' || TO_CHAR(SYSDATE,'YYYYMMDD HH24:MI:SS') || UTL_TCP.CRLF ||
'FROM:' || SENDER_ADDRESS || UTL_TCP.CRLF ||
'SUBJECT:' || SUBJECT || UTL_TCP.CRLF ||
'TO: '|| RECEIVER_ADDRESS || UTL_TCP.CRLF ||
'CONTENT-TYPE: TEXT/PLAIN; CHARSET=utf-8' || UTL_TCP.CRLF ||
'' || UTL_TCP.CRLF || CONTENTS || UTL_TCP.CRLF ;
UTL_SMTP.OPEN_DATA(CONN);
UTL_SMTP.WRITE_RAW_DATA(CONN,UTL_RAW.CAST_TO_RAW(MESG));
UTL_SMTP.CLOSE_DATA(CONN);
UTL_SMTP.QUIT(CONN);
END;
/
-------------------------------------------------
另:
Content-Type: text/plain;
Content-Type: text/plain; charset=ISO-8859-1
Content-Type: text/plain; charset=us-ascii
Content-Type: text/plain; charset=utf-8
Content-Type: text/html;
Content-Type: text/html; charset=ISO-8859-1
Content-Type: text/css
Content-Type: image/gif; name=image004.gif
Content-Type: image/jpeg; name="image005.jpg"
Content-Type: message/delivery-status
Content-Type: message/rfc822
Content-Type: audio/x-mpeg
Content-Type: video/mpeg-2
Content-Type: application/msword
Content-Type: application/mspowerpoint
Content-Type: application/zip
Content-Type: multipart/mixed; boundary="----=_Part_3431_12384933.1139387792352"
Content-Type: multipart/alternative; boundary="----=_Part_4088_29304219.1115463798628"
Content-Type: multipart/related; boundary="----=_Part_2067_9241611.1139322711488"
Content-Type: multipart/digest; boundary="----=Next message 15543233913938263541"
Content-Type: multipart/report; report-type=delivery-status;
boundary="k04G6HJ9025016.1136391237/carbon.singnet.com.sg"
Content-Type: multipart/parallel
1) Content-Type: multipart/mixed
它表明这封Email邮件中包含各种格式的MIME实体但没有具体给出每个实体的类型。
2) Content-Type: multipart/alternative
如果同一封Email邮件既以文本格式又以HTML格式发送,那么要使用Content-Type:
multipart/alternative。这两种邮件格式实际上是显示同样的内容但是具有不同的编码。
3) Content-Type: multipart/related
用于在同一封邮件中发送HTML文本和图像或者是其他类似类型。
邮件主体的编码:
主要是包括quoted-printable与base64两种类型的编码。
(待续)
附:常见的MIME类型
超文本标记语言文本 .html,.html text/html
普通文本 .txt text/plain
RTF文本 .rtf application/rtf
GIF图形 .gif image/gif
JPEG图形 .ipeg,.jpg image/jpeg
au声音文件 .au audio/basic
MIDI音乐文件 mid,.midi audio/midi,audio/x-midi
RealAudio音乐文件 .ra, .ram audio/x-pn-realaudio
MPEG文件 .mpg,.mpeg video/mpeg
AVI文件 .avi video/x-msvideo
GZIP文件 .gz application/x-gzip
TAR文件 .tar application/x-tar