The short procedure can be used to send a mail through PL/SQL.
Although there is a limitation to this as the code below does not allow you to send attachments. This can only be used to send text messages.
Although there is a limitation to this as the code below does not allow you to send attachments. This can only be used to send text messages.
CREATE OR REPLACE PROCEDURE email_message ( from_name VARCHAR2 , to_name VARCHAR2 , subject VARCHAR2 , MESSAGE VARCHAR2 ) IS l_mailhost VARCHAR2 (64) := 'server.com'; l_mail_conn UTL_SMTP.connection; BEGIN l_mail_conn := UTL_SMTP.open_connection (l_mailhost, 25); UTL_SMTP.helo (l_mail_conn, l_mailhost); UTL_SMTP.mail (l_mail_conn, from_name); UTL_SMTP.rcpt (l_mail_conn, to_name); UTL_SMTP.open_data (l_mail_conn); UTL_SMTP.write_data (l_mail_conn , 'Date: ' || TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || CHR (13) ); UTL_SMTP.write_data (l_mail_conn, 'From: ' || from_name || CHR (13)); UTL_SMTP.write_data (l_mail_conn, 'Subject: ' || subject || CHR (13)); UTL_SMTP.write_data (l_mail_conn, 'To: ' || to_name || CHR (13)); UTL_SMTP.write_data (l_mail_conn, Message ); UTL_SMTP.close_data (l_mail_conn); UTL_SMTP.quit (l_mail_conn); END; /
Emails with attachment can be done using Java as a wrapper. The metalink Note:120994.1 has a very good explanation on how to create a program that facilates sending emails with attachment.
No comments:
Post a Comment