|
| | Terms of Agreement:
By using this article, you agree to the following terms...
1) You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description. | create or replace package email_handler is
-- Author : Og Maciel aka Gnu Kemist
-- Created : 4/5/2002 4:14:05 PM
-- Purpose : To serve as an email handl
-- er object
procedure send_email(subjectin varchar2,
to_useridin varchar2 := NULL,
v_body in varchar2 := NULL,
from_namein varchar2 := NULL,
to_namein varchar2 := NULL,
content_type in varchar2 := NULL);
end email_handler;
create or replace package body email_handler is
/*
Procedure: send_email
Author: Og Maciel aka Gnu Kemist
Purpose:
*/
procedure send_email(subjectvarchar2,
to_useridvarchar2 := NULL,
v_bodyvarchar2 := NULL,
from_namevarchar2 := NULL,
to_namevarchar2 := NULL,
content_type varchar2 := NULL)
IS
c utl_smtp.connection;
from_userid varchar2(40) := 'webmaster@yourcompany.com';
send_user varchar2(40);
from_domain VARCHAR2(200) := SUBSTR(from_userid,INSTR(from_userid,'@')+1);
smtp_server varchar2(50) := 'YOUR_SERVER_NAME';
my_body varchar2(32000);
PROCEDURE header(name VARCHAR2, value VARCHAR2) IS
BEGIN
utl_smtp.write_data(c, name || ': ' || value || utl_tcp.CRLF);
END;
BEGIN
if to_userid is null then
send_user := user || '@yourcompany.com'; -- This sends email to current user logged in
else
send_user := to_userid;
end if;
my_body := v_body;
c := utl_smtp.open_connection(smtp_server);
utl_smtp.helo(c, from_domain );
utl_smtp.mail(c, from_userid );
utl_smtp.rcpt(c, send_user );
utl_smtp.open_data(c);
header('From','"'||NVL(from_name,from_userid)||'" <'||from_userid||'>');
header('To','"'||NVL(to_name,to_userid)||'" <'||to_userid||'>');
header('Subject', subject );
header('Content-Type', NVL(content_type,'text/html'));
utl_smtp.write_data(c, utl_tcp.CRLF || my_body );
utl_smtp.close_data(c);
utl_smtp.quit(c);
EXCEPTION
WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
utl_smtp.quit(c);
end send_email;
end email_handler;
| | Download article
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzipto decompress it.
Virus note:All files are scanned once-a-day by Planet Source Code for viruses,but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE: 1)Re-scan downloaded files using your personal virus checker before using it. 2)NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com
| Terms of Agreement:
By using this article, you agree to the following terms...
1) You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description. | | Report Bad Submission | | | Your Vote! |
See Voting Log | | Other User Comments | 5/15/2002 10:19:35 AM:Gnu Kemist I kindly ask you all to rate my code...
| 5/20/2002 8:40:44 PM:KC can you re-format the coding, it's
kinda hard to read....
BTW, do we
need to configure the SQL Email?
| 5/21/2002 1:37:31 PM:Daniel i like to test it.
| 5/21/2002 1:58:57 PM:Gnu Kemist The article is now presented as a text
file for download in order to preserve
all the formatting. I ask that those
who were kind enough to send me a
comment, to rate my code.
Thank you
| | Add Your Feedback! | Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.
NOTICE: The author of this article has been kind enough to share it with you. If you have a criticism, please state it politely or it will be deleted.
For feedback not related to this particular article, please click here. | | |