Apr 172011
 

1. UTL_SMTP

CREATE OR REPLACE PROCEDURE erpschools_send_email
 
IS
 
mailhost varchar2 (30) := 'smtp.erpschools.com';
 
crlf varchar2(2)Â := CHR (13) || CHR (10);
 
v_email varchar2(16000);
 
message_1 LONG;
 
mail_conn utl_smtp.connection;
 
BEGIN
 
mail_conn := utl_smtp.open_connection (mailhost, 25);
 
utl_smtp.helo (mail_conn, mailhost);
 
utl_smtp.mail (mail_conn, 'sender@erpschools.com');
 
utl_smtp.rcpt (mail_conn, 'receiver@erpschools.com');
 
message_1 := 'From: Mr Sender < sender@erpschools.com >' || crlf ||
 
'Subject: Testing Hyperlink' || crlf ||
 
'To: Mrs Receiver <Receiver@erpschools.com>' || crlf ||
 
'<a href="http://www.erpschools.com" target="new" www.erpschools.com</a>' || crlf || crlf ;
 
utl_smtp.data(mail_conn, 'MIME-Version: 1.0' ||CHR(13)||CHR(10)||'Content-type: text/html' || CHR(13)||CHR(10)||message_1);
 
utl_smtp.quit (mail_conn);
 
END;

2. UTL_MAIL: This is the new package introduced in 10g. even though this uses the UTL_SMTP in the background the advantage with this script is we can change the mail server and ports in the configuration file with out changing the code.

I will update this very soon.

Related Articles:

  1. Ship Confirm through API
  2. Email the output of a concurrent program as Attachment
  3. Revenue Adjustment Script

admin

 Posted by at 3:12 pm

  2 Responses to “Send e mail through PL SQL code”

  1. Hey…

    how to send email to multiple receipants?? rather than single 1.

    Thanks,

  2. Hi,

    In the above to send mail for one receipants try to add more with ‘;’, seperated hope that works

    Thanks,
    Manoj

 Leave a Reply

[Social Login] Please enable at least one social network!

*

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>