Let us see how we can utilize UTL_MAIL to send Email form PL/SQL. Using the UTL_MAIL package is pretty straight forward.
Check the below example.

begin
   utl_mail.send(
      sender     => 'oracle@mydomain.com',
      recipients => 'user1@mydomain.com,user2@mydomain.com',
      subject    => 'Test Mail from my Instance',
      message    => 'Test message'
                );
end;

As you can see there are 4 different entities that you need to consider.

  • Sender’s Email Id
  • Recipient’s Email Id – You may include one or more recipients.
  • Subject of the Email
  • Message

Let me know if you have any questions on the topic. Your feedback and suggestions are highly appreciated.


Comments

2 responses to “UTL_MAIL to Send Email form PL/SQL”

  1. Can we send attachments using utl_mail.send ?

    1. Hi Sankar,

      I believe you can. However you will have to give the contents for the file in the UTL_MAIL code snippet itself. You may not be able to just give the path name and expect it to be attached.

      What i usually do is spool the file to a directory and then use uuencode or mailx or mail (unix commands) to attach the file to the email. You can also attach file directory from the output directory using any of the above mentioned unix commands.

      Let me know if you have questions.

      Thanks,
      Arun

Questions? Comments? Suggestions? Let us know!! Like / Subscribe / Follow for more updates.