Salim berbagi…. tempat belajar dan berinteraksi….


Program untuk Email Otomatis
January 26, 2010, 2:22 AM
Filed under: ORACLE

Artikel di bawah ini bisa digunakan untuk membuat job atau schedule pengiriman email secara otomatis. Di ambil dari mailing list ORAID.

=======================================================================

1. Buat Procedure Send Mail terlebih dahulu
CREATE OR REPLACE PROCEDURE send_mail (
pSender VARCHAR2,
pRecipient VARCHAR2,
pSubject VARCHAR2,
pMessage LONG) IS

mailhost CONSTANT VARCHAR2(30) := ‘10.9.0.1’;
crlf CONSTANT VARCHAR2(2): = CHR(13) || CHR(10);
mesg LONG;
mail_conn utl_smtp.connection ;

BEGIN
mail_conn := utl_smtp.open_ connection( mailhost, 25);

mesg := ‘Date: ‘ ||
TO_CHAR( SYSDATE, ‘dd Mon yy hh24:mi:ss’ ) || crlf ||
‘From: <‘|| pSender ||’>’ || crlf ||
‘Subject: ‘|| pSubject || crlf ||
‘To: ‘||pRecipient || crlf || ” || crlf || pMessage;

utl_smtp.helo( mail_conn, mailhost);
utl_smtp.mail( mail_conn, pSender);
utl_smtp.rcpt( mail_conn, pRecipient);
utl_smtp.data( mail_conn, mesg);
utl_smtp.quit( mail_conn) ;

END send_mail;
/

2. Kemudian jalankan procedure send mail di SQL, misalkan
EXEC send_mail (‘fromuser@xxx. com‘,‘touser@xxx. com‘,’Test’,’Test test 1 2 3′);

3. Selanjutnya tinggal bikin schedule di DBMS_JOB.


Leave a Comment so far
Leave a comment



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s



%d bloggers like this: