HTML,XML,stored,procedure,will,allow,send,ema
Quick Search for:  in language:    
HTML,XML,stored,procedure,will,allow,send,ema
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
SQL Stats

 Code: 24,836 lines
 Jobs: 419 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for SQL.
Click here to see a screenshot of this code!Num2Guid Conversion Function
By Lewis Moten on 5/24

(Screen Shot)

Click here to see a screenshot of this code!Int2GUID
By Lewis Moten on 5/24

(Screen Shot)

Click here to see a screenshot of this code!FormatDate
By Lewis Moten on 5/22

(Screen Shot)

Function That will work as initcap function of Oracle
By Hemant Kailashchand Garg on 5/20


How to create views and use them - *VOTE PLEASE*
By hamsters at xssi.net on 5/15


Send email through PL/SQL
By Gnu Kemist on 5/14


Log Record Changes
By Lewis Moten on 5/14


pl/sql mega tutorial
By somdutt ganguly on 5/14


SqlShell
By Micronet on 5/13


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Send email through PL/SQL

Print
Email
 

Submitted on: 5/14/2002 4:33:19 PM
By: Gnu Kemist  
Level: Advanced
User Rating: By 2 Users
Compatibility:Oracle

Users have accessed this article 1251 times.
 

(About the author)
 
     This stored procedure will allow you to send email to your users (or even yourself) with job status or even serve as an error reporting tool for your application. You could call it from other stored procedures or triggers upon insert/update/delete statements; or call it from a visual basic application to send you an email when an error occurrs; The uses are almost that unlimited! You can improve this procedure to send HTML or XML emails... Have fun and please vote!

This article has accompanying files
 
 
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;

winzip iconDownload 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
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this article(in the Advanced category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
5/15/2002 10:19:35 AM:Gnu Kemist
I kindly ask you all to rate my code...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
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?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/21/2002 1:37:31 PM:Daniel
i like to test it.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
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
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
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.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | SQL Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.