Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

utl_smtp - email file attachments

sliderrulesMay 27 2015 — edited May 28 2015

Hi,

I have a requirement to email some files off the Linux server to some users. The files are the output of a SQL loader job (.log file and .BAD files).

I have a simple script that generates an email:

DECLARE

  mailhost  VARCHAR2(64) := 'fake.net';

  sender    VARCHAR2(64) := 'someone@happy-days.net';

  recipient VARCHAR2(64) := 'boss@fake.net';

  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);

  utl_smtp.rcpt (mail_conn, recipient);

  utl_smtp.open_data (mail_conn);

  utl_smtp.write_data (mail_conn, 'Test' || chr(13));

  utl_smtp.write_data (mail_conn, 'Test Attachments' || chr(13));

  utl_smtp.close_data (mail_conn);

  utl_smtp.quit (mail_conn);

END;

/

How can the attachments be incorporated into the above script.

The files are located on the server directory /db/home/files/sqlloader/

file names - e.g. load.BAD & load.log

Both files would need to be attached in the email. can anyone suggest how this can be achieved?

Thanks

This post has been answered by Billy Verreynne on May 28 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 25 2015
Added on May 27 2015
18 comments
3,227 views