I have a file on local drive let's say C:\test\att.csv. I had configured PL/SQL procedure to gather data from database and send an email. The att.csv file contains some values which I have send as an attachment of the email. Can you please help me how to do that. Below is my current code.
EXECUTE IMMEDIATE 'ALTER SESSION SET smtp_out_server = ''abcd.abc.ab''';
UTL_MAIL.send(sender => '[email protected]',
recipients => '[email protected]',
subject => 'Test Databases'',
message => v_htmlbody,
mime_type => 'text/html; charset=us-ascii');
To send an attachment using
UTL_MAIL
you need to use eitherUTL_MAIL.send_attach_raw
orUTL_MAIL.send_attach_varchar2
. Refer to https://docs.oracle.com/database/121/ARPLS/u_mail.htm#ARPLS71208 for the parameters to pass, includingattachment
andatt_filename
. These procedures require that the data for the attachment is available in a RAW or VARCHAR2 format.If the attachment is on the local disk on the database server, you can load the data using
UTL_FILE
. Refer to: https://docs.oracle.com/database/121/ARPLS/u_file.htm#ARPLS069