Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2003
    Posts
    15

    Unanswered: Sending Mail from database

    Is there any way to send an email message from an Oracle stored procedure?

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Sending Mail from database

    Use UTL_SMTP. Here is a simple example:
    Code:
    DECLARE
      l_mailhost VARCHAR2(255) := 'smpt.mydomain.com';
      l_mail_conn utl_smtp.connection;
    BEGIN
      l_mail_conn := utl_smtp.open_connection( l_mailhost );
      utl_smtp.helo(l_mail_conn, l_mailhost);
      utl_smtp.mail(l_mail_conn, 'me@mydomain.com');
      utl_smtp.rcpt(l_mail_conn, 'you@yourdomain.net');
      utl_smtp.open_data(l_mail_conn);
      utl_smtp.write_data(l_mail_conn,'Hello');
      utl_smtp.close_data(l_mail_conn);
      utl_smtp.quit(l_mail_conn);
    END;
    /

  3. #3
    Join Date
    Jan 2004
    Posts
    2

    Re: Sending Mail from database

    Originally posted by brewerd
    Is there any way to send an email message from an Oracle stored procedure?
    Sure it is. Read about PSP_Mail is a set of PL/SQL packages and Java classes that simplify the task of sending various types of e-mail from Oracle8i/9i PL/SQL applications.

    http://www.dynamicpsp.com/dpsp/prod/!go?id_=p_mail

  4. #4
    Join Date
    Jan 2004
    Posts
    2

    Re: Sending Mail from database

    Originally posted by andrewst
    Use UTL_SMTP. Here is a simple example:
    Code:
    DECLARE
      l_mailhost VARCHAR2(255) := 'smpt.mydomain.com';
      l_mail_conn utl_smtp.connection;
    BEGIN
      l_mail_conn := utl_smtp.open_connection( l_mailhost );
      utl_smtp.helo(l_mail_conn, l_mailhost);
      utl_smtp.mail(l_mail_conn, 'me@mydomain.com');
      utl_smtp.rcpt(l_mail_conn, 'you@yourdomain.net');
      utl_smtp.open_data(l_mail_conn);
      utl_smtp.write_data(l_mail_conn,'Hello');
      utl_smtp.close_data(l_mail_conn);
      utl_smtp.quit(l_mail_conn);
    END;
    /
    That's right.
    But how using your code to send an attachment or more then one ?

  5. #5
    Join Date
    Jan 2004
    Posts
    492

    Re: Sending Mail from database

    Originally posted by brewerd
    Is there any way to send an email message from an Oracle stored procedure?

    Either :

    1) Search the board b/c Ive seen this posted many times

    2) Go to otn.oracle.com and search the forums b/c i see that there all the time as well.

    3) Check out asktom.oracle.com - he has covered this many times too

    4) Check out the Oracle Supplied utl_smtp package - this is what you'll actually need to email.

  6. #6
    Join Date
    Jan 2004
    Posts
    492
    wow - 3 posts within 2 minutes of each other - thats damn good response time

  7. #7
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Sending Mail from database

    Originally posted by andrew_toropov
    That's right.
    But how using your code to send an attachment or more then one ?
    I don't have a clue - I did say it was a simple example ;o)

Posting Permissions

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