Oracle by Example brandingOracle Application Express 18: Email Templates (2 of 2) - Call the Template

section 0Before You Begin

This 15-minute tutorial demonstrates how to call an email template to send out email notifications for upcoming milestones in Sample Projects application.

This is the second tutorial in the series Oracle Application Express 18: Email Templates. Read the tutorials in the following sequence:

Background

In the previous tutorial, you installed the Sample Projects application and created an email template.  In this tutorial, you create a procedure to call the email template and add a button and process to call the procedure.

What Do You Need?

To complete this tutorial you need to:

  • Complete the preceding tutorial in this series.


section 1Create a Procedure Using the apex_mail.send API

To create a procedure using the apex_mail.send API:

  1. On the Workspace home page, click SQL Workshop.
  2. Click SQL Commands.
  3. In SQL Commands, copy and paste the code in send_milestone_reminder.txt.
    Pasted code in SQL Commands
    Description of the illustration create_procedure.png
  4. Click Run. The following message displays below the Results tab:
    Procedure Created.
  5. Click the App Builder menu at the top of the page. The App Builder home page appears.

section 2Add a Button to the Milestones Page

To add a button:

  1. On the App Builder home page, select the Sample Projects application.
  2. On the Application home page, find and select 6, Milestones. Page Designer appears.
  3. From the Gallery at the bottom of page:
  4. In the Property Editor, update:
    • Identification: Button Name - Enter Email
    • Identification: Label - Enter Email Reminder
  5. Click Save.

section 3Create a Process to Call the Procedure

To create a process :

  1. In the left pane, select the Processing tab.
    Processing
    Description of the illustration processing_tab.png
  2. Select Processing. Select the Processing Menu and then select Create Process.
    Create Process
    Description of the illustration create_process.png

    A process called New appears under Processes and attributes display in the Property Editor (right pane).

    New process
    Description of the illustration new_process.png
  3. In the Property Editor, edit the following:
    • Identification: Name - Enter Email Reminder
    • Source: PL/SQL Code - Enter:
      
      begin
        SEND_MILESTONE_REMINDER;
      end;
                          
    • Success Message: Success Message - Enter:
      Emails sent to all Project Leads with Milestones due in the next two weeks
    • Success Message: Error Message - Enter:
      Error sending emails
  4. Click Save.

section 4Update Team Member with Valid Email Address

When you installed Sample Projects, the installation process automatically created a Team Member that matches your workspace username. Before you can test the new Email Reminder button, you need update that Team Member to include a valid email address.

To add a valid email address:

  1. Click Run and Save Page.
    Run and Save Page
    Description of the illustration pg6_save_and_run.png
  2. If a Sign dialog appears, enter your workspace username and password and click Log In. The Milestones page appears.
    Milestones
                  page
    Description of the illustration milestones_pg.png"
  3. In the left navigation menu, select Team Members. The Team Members page appears.
  4. On the Team Members page, find and select the username which matches your workspace username. Look for the Profile, I'm the one who ran this data script to populate these demo tables. In the following example, the user is Admin.
    Admin user
    Description of the illustration edit_user.png
  5. In the Maintain Team Member dialog:
  6. In the left navigation menu, select Milestones. The Milestones page appears.

section 5Test the Button

To test the button:

  1. On the Milestones page, note the Email Reminder button in the upper right corner above the report.
    Email Reminder button
    Description of the illustration test_button.png
  2. Click the Email Reminder button.

    The following Success appears:
    Emails sent to all Project Leads with Milestones due in the next two weeks

    Email Reminder message
    Description of the illustration success_message.png
  3. Check the email account tied to your workspace user. You should receive an email for all active projects.
  4. This ends the second and final tutorial in this series.


more informationWant to Learn More?