DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: sending an attachment by using utl_smtp

  1. #1
    Join Date
    Sep 2006
    Posts
    114

    sending an attachment by using utl_smtp

    i have created the following procedure for sending email
    its working fine but i want to send an attachment file with email and i didn't find any help
    Can anybody help me in this regard?

    CREATE OR REPLACE PROCEDURE email_from_plsql IS
    tmpVar NUMBER;
    c UTL_SMTP.CONNECTION;

    PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
    BEGIN
    UTL_SMTP.WRITE_DATA(c, name || ': ' || header || UTL_TCP.CRLF);
    END;
    BEGIN
    -- Open connection to SMTP gateway
    c := UTL_SMTP.OPEN_CONNECTION('192.168.0.12',25);
    UTL_SMTP.HELO(c, '192.168.0.12');
    UTL_SMTP.MAIL(c, 'mshakeel@nctex.com');
    UTL_SMTP.RCPT(c, 'mshakeel@nctex.com');
    UTL_SMTP.RCPT(c, 'afzaal@nctex.com');
    UTL_SMTP.OPEN_DATA(c);
    send_header('From','mshakeel@nctex.com');
    send_header('To','mshakeel@nctex.com');
    send_header('Cc','afzaal@nctex.com');
    send_header('Subject','Automated Database Email');
    UTL_SMTP.WRITE_DATA(c, utl_tcp.CRLF || 'This is an automated email from the Oracle database.');
    UTL_SMTP.WRITE_DATA(c, utl_tcp.CRLF || 'The database is working for you!');
    UTL_SMTP.CLOSE_DATA(c);
    UTL_SMTP.QUIT(c);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    Null;
    WHEN OTHERS THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END email_from_plsql;
    /

  2. #2
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,492

    Cool


    You forgot to ask tom!

    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width