--#############################################################################
--# Name : p_tprint
--# Description : This procedure is to send notification emails
--#
--# History
--# Date Author Ver. Comments
--# ----------- ----------------- ---- ----------------------------------------
--#############################################################################
PROCEDURE NotificationMail (p_recipent_email_id VARCHAR2, p_message VARCHAR2)
IS
v_sender_email_id VARCHAR2 (100) := 'Oracle-Support.CG-EUR@nuthan.com';---sender mail id
v_cc_email_id VARCHAR2 (100) := 'nuthanmechanical@gmail.com ';
v_subject VARCHAR2 (50) := '****Alert mail*****';
v_hostname VARCHAR2 (50) := 'webmail.nuthan.com';--server address
v_mail_conn UTL_SMTP.connection;
v_crlf VARCHAR2 (10) := CHR (13) || CHR (10);---you ca use utl_tcp as well
v_email_list VARCHAR2 (4000);
v_separator VARCHAR2 (1) := ',';
BEGIN
BEGIN
v_mail_conn := UTL_SMTP.open_connection (v_hostname, 25);
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (
fnd_file.LOG,
' Error while creating connection Error: ' || SQLERRM);
END;
BEGIN
UTL_SMTP.helo (v_mail_conn, v_hostname);
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (
fnd_file.LOG,
' Error while saying Helo to server Error: ' || SQLERRM);
END;
BEGIN
UTL_SMTP.mail (v_mail_conn, v_sender_email_id);
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (
fnd_file.LOG,
' Error while creating mail Error: ' || SQLERRM);
END;
BEGIN
v_email_list := p_recipent_email_id;
LOOP
IF (INSTR (v_email_list,
v_separator,
1,
1) > 0)
THEN
UTL_SMTP.rcpt (v_mail_conn,
SUBSTR (v_email_list,
1,
INSTR (v_email_list,
v_separator,
1,
1)
- 1));
v_email_list :=
SUBSTR (v_email_list,
INSTR (v_email_list,
v_separator,
1,
1)
+ 1);
ELSE
UTL_SMTP.rcpt (v_mail_conn, v_email_list);
EXIT;
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (
fnd_file.LOG,
' Error while adding recipients Error: ' || SQLERRM);
END;
UTL_SMTP.open_data (V_mail_conn);
UTL_SMTP.write_data (v_mail_conn,
'From :' || v_sender_email_id || v_crlf);
UTL_SMTP.write_data (v_mail_conn, 'Subject :' || v_subject || v_crlf);
UTL_SMTP.write_data (v_mail_conn,
'To :' || p_recipent_email_id || v_crlf);
UTL_SMTP.write_data (
v_mail_conn,
'Content-Type: text/html; charset="UTF-8"'
|| UTL_TCP.crlf
|| UTL_TCP.crlf);
UTL_SMTP.write_data (v_mail_conn, p_message || v_crlf);
UTL_SMTP.close_data (v_Mail_Conn);
UTL_SMTP.quit (v_mail_conn);
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (
fnd_file.LOG,
'Error occured while processing sendmail program' || SQLERRM);
END NotifiactionMail;