declare
CRLF CONSTANT varchar2(10) := utl_tcp.CRLF;
BOUNDARY CONSTANT varchar2(256) := '-----7D81B75CCC90D2974F7A1CBD';
FIRST_BOUNDARY CONSTANT varchar2(256) := '--'||BOUNDARY||CRLF;
LAST_BOUNDARY CONSTANT varchar2(256) := '--'||BOUNDARY||'--'||CRLF;
MULTIPART_MIME_TYPE CONSTANT varchar2(256) := 'multipart/mixed; boundary="'||BOUNDARY||'"';
mail_conn utl_smtp.connection;
sender VARCHAR2(200);
mhost VARCHAR2(30);
inRecipient VARCHAR2(100);
inMessage VARCHAR2(100);
mime_type varchar2(255) := 'text/html';
attachment_file_name varchar2(255) := 'abc.txt';
--attachment_file_name varchar2(255) := 'abc.txt';
PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
BEGIN
utl_smtp.write_data(mail_conn, name || ': ' || header || utl_tcp.CRLF);
END;
procedure send_receive_header(name in varchar2, header in varchar2) is
begin
utl_smtp.write_data(mail_conn, name||': '||header||CRLF);
end;
BEGIN
inMessage :='DENEME1';
inRecipient:='ctahtaci@yfas.com.tr';
mhost:='193.193.193.96';
mail_conn := utl_smtp.open_connection(mhost, 25);
sender :='ct_deneme_attach@yfas.com.tr';
utl_smtp.helo(mail_conn, mhost);
utl_smtp.mail(mail_conn, sender);
utl_smtp.rcpt(mail_conn, inRecipient);
utl_smtp.open_data(mail_conn);
send_header('From', 'xxxxx');
send_header('To', '"Recipient"
send_header('Subject', 'Hello1');
send_header('Content-Type',MULTIPART_MIME_TYPE);
--utl_smtp.write_data(c, utl_tcp.CRLF || 'Hello, world!');
-- utl_smtp.data(mail_conn, inMessage);
----------------------------------------
-- Send the main message text
----------------------------------------
-- mime header
utl_smtp.write_data(mail_conn, FIRST_BOUNDARY);
send_receive_header('Content-Type',mime_type);
utl_smtp.write_data(mail_conn, CRLF);
utl_smtp.write_data(mail_conn, 'see attachment');
utl_smtp.write_data(mail_conn, CRLF);
-- add the attachment
utl_smtp.write_data(mail_conn, FIRST_BOUNDARY);
send_receive_header('Content-Type',mime_type);
send_receive_header('Content-Disposition','attachment; filename= '||attachment_file_name);
utl_smtp.write_data(mail_conn, CRLF);
utl_smtp.write_data(mail_conn, 'This is the attachment and this text is written in add attachement section');
utl_smtp.write_data(mail_conn, CRLF);
-- Close the message
utl_smtp.write_data(mail_conn, LAST_BOUNDARY);
utl_smtp.close_data(mail_conn);
utl_smtp.quit(mail_conn);
EXCEPTION
WHEN OTHERS THEN
null;
END;
Hiç yorum yok:
Yorum Gönder