As of Oracle 8.1, you can now send email from within an Oracle application. This is done by using the UTL_SMTP package. However, it should be noted that there are some shortcomings with this package that may or may not be a problem for you: 1. You cannot send a Subject line with your email. Another gotchya is that you have to include an end-of-line sequence after each line in your message. In order to simplify sending emails, I created a procedure called (cleverly enough!) "email". It accepts the email recipient, a subject, and a message as arguments. I hardcoded my email address and mail server. Please note that the subject gets included as the first line in the body of the message as a convenience to the recipient. In order to make this more generic in a production environment,
you might also want to add the Sender and Mail Server information as arguments
to the procedure. PROCEDURE email(p_target IN VARCHAR2, --PURPOSE: SEND p_message TO p_target VIA EMAIL. v_eol VARCHAR2(2) := chr(13)||chr(10); -- EOL CHARACTERS -- BUILD THE MAIL MESSAGE AND SEND IT OUT -- SEVER THE CONNECTION EXCEPTION |
See also :