Professional Documents
Culture Documents
Alert Package
Alert Package
v_connection UTL_SMTP.connection;
-- mime blocks (the sections of the email body that can become attachments)
-- must be delimited by a string, this particular string is just an example
c_mime_boundary CONSTANT VARCHAR2(256) := '-----AABCDEFBBCCC0123456789DE';
--v_clob CLOB := EMPTY_CLOB();
v_len INTEGER;
v_index INTEGER;
v_email varchar2(10000);
v_Cc varchar2(10000);
v_text varchar2(10000) := 'Dear Sir,
Regards,
Interface Program
';
l_message VARCHAR2(32767) := '<html>
<body>
<br>
Test HTML with Embedded Image-chk latest
<p>And here it is:</p>
<p>The end.</p>
</body>
</html>
';
BEGIN
-- Build the contents before connecting to the mail server
-- that way you can begin pumping the data immediately
-- and not risk an SMTP timeout
v_email := 'Niaz.Ahmad@kb.com.pk,
Afzal.Amin@kb.com.pk,
Irfan.Khan@kb.com.pk,
Muhammad.Umar@kb.com.pk';
v_Cc := 'pwc.consultant1@Kb.com.pk';
v_connection := UTL_SMTP.open_connection('10.10.1.81');
UTL_SMTP.helo(v_connection, '10.10.1.81');
UTL_SMTP.mail(v_connection, 'Infotech.HRMS@Kb.com.pk');
UTL_SMTP.rcpt(v_connection, 'pwc.consultant1@Kb.com.pk');
UTL_SMTP.rcpt(v_connection, 'Niaz.Ahmad@kb.com.pk');
UTL_SMTP.rcpt(v_connection, 'Afzal.Amin@kb.com.pk');
UTL_SMTP.rcpt(v_connection, 'Irfan.Khan@kb.com.pk');
UTL_SMTP.rcpt(v_connection, 'Muhammad.Umar@kb.com.pk');
UTL_SMTP.open_data(v_connection);
UTL_SMTP.write_data(v_connection,
'From: ' || 'Infotech.HRMS@Kb.com.pk' ||
UTL_TCP.crlf);
UTL_SMTP.write_data(v_connection,
'To: ' || v_email --'pwc.lhr@bankalfalah.com'
|| UTL_TCP.crlf);
UTL_SMTP.write_data(v_connection, 'CC: ' || v_Cc || UTL_TCP.crlf);
UTL_SMTP.write_data(v_connection,
'Subject: ' || v_Subject || UTL_TCP.crlf);
-- UTL_SMTP.write_data(v_connection, 'Body: some text.....'|| UTL_TCP.crlf);
-- UTL_SMTP.write_data(v_connection, 'Some Message Text.....' || UTL_TCP.crlf
|| UTL_TCP.crlf);
UTL_SMTP.write_data(v_connection, 'MIME-Version: 1.0' || UTL_TCP.crlf);
UTL_SMTP.write_data(v_connection,
'Content-Type: multipart/mixed; boundary="' ||
c_mime_boundary || '"' || UTL_TCP.crlf);
UTL_SMTP.write_data(v_connection, UTL_TCP.crlf);
UTL_SMTP.write_data(v_connection,
'This is a multi-part message in MIME format.' ||
UTL_TCP.crlf);
-- UTL_SMTP.write_data(v_connection, UTL_TCP.CRLF);
-- UTL_SMTP.write_data(v_connection, l_message);
-- UTL_SMTP.write_data(v_connection, UTL_TCP.CRLF);
UTL_SMTP.write_data(v_connection,
'--' || c_mime_boundary || UTL_TCP.crlf);
UTL_SMTP.write_data(v_connection,
'Content-Type: text/plain charset="iso-8859-1"' ||
UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.write_data(v_connection, v_text);
UTL_SMTP.write_data(v_connection, UTL_TCP.crlf || UTL_TCP.crlf);
v_len := DBMS_LOB.getlength(v_clob);
v_index := 1;
--
-- End attachment
UTL_SMTP.write_data(v_connection, UTL_TCP.crlf);
UTL_SMTP.write_data(v_connection,
'--' || c_mime_boundary || '--' || UTL_TCP.crlf);
UTL_SMTP.close_data(v_connection);
UTL_SMTP.quit(v_connection);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.put_line('Alert Pro Error');
-- DBMS_OUTPUT.put_line( 'Alert Pro Error' ||
DBMS_UTILITY.format_error_stack);
END;