Friday, 24 January 2014

USING plsql sending to email

CREATE OR REPLACE PROCEDURE xx_plsql_test_mail_pro (
errbuf OUT VARCHAR2,
retcode OUT VARCHAR2
)
IS
v_from VARCHAR2 (80) := 'root@erpr12.dakshahebiz.com';
v_recipient VARCHAR2 (80) := 'yallamandareddy@gmail.com';
v_recipient1 VARCHAR2 (80) := 'snalam037@gmail.com';
v_recipient2 VARCHAR2 (80) := 'bharath6886@gmail.com';
v_subject VARCHAR2 (80) := 'Yallamanadareddy Send To u';
v_mail_host VARCHAR2 (30) := 'erpr12.dakshahebiz.com';
v_mail_conn UTL_SMTP.connection;
crlf VARCHAR2 (2) := CHR (13) || CHR (10);
BEGIN
v_mail_conn := UTL_SMTP.open_connection (v_mail_host, 25);
UTL_SMTP.helo (v_mail_conn, v_mail_host);
UTL_SMTP.mail (v_mail_conn, v_from);
UTL_SMTP.rcpt (v_mail_conn, v_recipient);
UTL_SMTP.rcpt (v_mail_conn, v_recipient1);
UTL_SMTP.rcpt (v_mail_conn, v_recipient2);
UTL_SMTP.DATA (v_mail_conn,
'Date: '
|| TO_CHAR (SYSDATE, 'Dy, DD Mon YYYY hh24:mi:ss')
|| crlf
|| 'From: '
|| v_from
|| crlf
|| 'Subject: '
|| v_subject
|| crlf
|| 'To: '
|| v_recipient
|| crlf
|| crlf
|| 'hhhhhhhhhhhiiiiiiiiiiiiiiiii'
|| crlf
|| -- Message body
|| 'ITU CHUDU'
||'HELLO'

);
UTL_SMTP.DATA (v_mail_conn,HTP.PRINT('<html>'));
UTL_SMTP.quit (v_mail_conn);
EXCEPTION
WHEN UTL_SMTP.transient_error OR UTL_SMTP.permanent_error
THEN
raise_application_error (-20000, 'Unable to send mail: ' || SQLERRM);
END;

No comments:

Post a Comment