*
| [PlanetJ Corporation
[support@planetJavaInc.com] [www.PlanetJavaInc.com] |

WOW Email is a separately licensed, fee based add-on that allows users to create, manage and send email from a WOW Application. Another feature of WOW Email is the ability to have email sent to a specific account when someone inserts or updates a field in a specific table. The newest feature of WOW Email is the ability to use a URL call to send email. This is a very powerful feature as it can be set up via a task scheduler to auto run at a time specified by the user.
The uses for WOW Email are almost limitless. You can create a form email and send statements or bills to customers, using replacement variables to fill in their personal information. You can use it to manage and monitor your database by setting up a confirmation email to be sent when someone modifies the database. Anything you can do via webmail or client-based email can be done with WOW Email. Simple, powerful, WOW!
Installation Instructions
Accessing the WOW Mail Application
Email Server Entries
Other Control Settings
SMTP Mail Server Settings
Email Address Settings
Email Batch Settings
Email Entry File
Confirmation Email Settings
Email Entries
Control Settings
Other Email Settings
Email Recipients
Confirmation Email Settings
Configuring Auto Send Email
Configuring Manual Send Email
Configuring Confirmation Send Email
SendEmail API
URL Call
Using SendEmail to Send a Pre-configured Email Entry
Supported URL Parameters (parameter names are case sensitive):
Using SendEmail to Send an Email with the Content Generated from a WOW Operation
Supported URL Parameters (parameter names are case sensitive):
Direct Java Class Call
Sending an Email With the Email Content Generated from a WOW Operation
Constructor Parameters:
Sending Email Using a Pre-configured Email Entry
Constructor Parameters:
Creating Automated Email with WOW SendEmail
Scheduling Tasks with runURL
Using the Results of a Row Collection as a Distribution List
Installation Instructions
1. Restore the WOW metadata library (WOWMAIL65):
a) i5 or AS400:
1) Ftp the save file provided (wowmail.savf) to your i5. Assuming the save file created has the same name, then
2) RSTLIB SAVLIB(WOWMAIL65) DEV(*SAVF) SAVF(WOWMAIL65) MBROPT(*ALL) ALWOBJDIF(*ALL)
b) MySQL:
1) Start up the MySQL Adminstrator for your MySQL DB.
2) Click on the Restore option.
3) Click on the Open Backup File button and select the sql file provided (wowmail65.sql).
4) You should be able to leave the settings to their default values. Restore the catalog wowmail65 by clicking on the "Start Restore" button.
2. Add the Email jar to your existing WOW webcontext in Tomcat (if you already have WOW installed). This is needed for adding email functionality to your WOW product:
a) Copy wow-email-X.X.jar and commons-email-X.X.jar(where X.X is the current version) found in this .zip file and paste it into your existing webapp's lib folder:
~\Tomcat 6.0\webapps\wow65\WEB-INF\lib
b) Restart Tomcat to pickup the new jar files and the new web application.
Accessing the WOW Mail Application
To access the WOW Mail application, open a web browser. Navigate to a URL similar to the following: http:// [ localhost:8080/wow70] /run?id=0&_pj_lib=wowmailXX You will need to replace the bracketed ([ ]) section of the URL with your WOW URL (something like www.mycompany.com/wow65/) and the XX with the metadata version of WOW Mail you are using.
Email Server Entries
From the WOW Mail application, this menu item (Email Setup > Work with Email Server Entries) lets you define an email server entry to be used for sending email. You'll need email server and account information (similar to what you would use for email programs such as Microsoft Outlook or Thunderbird):

Other Control Settings
- Control ID – Unique record ID, set by WOW.
- Connection Alias – Connection name to use when sending email.

SMTP Mail Server Settings
- Server IP Address – SMPTP email server IP to use for sending email.
- User ID – Email account user ID to use for sending email.
- Password - Email account password to use for sending email.

Email Address Settings
- To Address – Email “To Address” used when testing this email control entry for validity.
- From Address – Email “From Address” used when testing this email control entry for validity. Also the default “From Address” used by email entries when no “From Address” is specified in the email entry.

Email Batch Settings
- Auto-send is Active for this entry – When auto-send email is configured, determines whether email entries corresponding to this control record should be sent automatically as scheduled.

Email Entry File
- File Name – The file used to contain the email entries. EMAILLOG should already exist in WOWMAIL64 and is the default.
- Library Name - The library used to contain the e\mail entries. EMAILLOG should already exist in WOWMAIL64 and is the default.

Confirmation Email Settings
- Default Option – If a confirmation email operation is defined, but there is no corresponding entry in the email entries, this control record is used for sending a default confirmation email.
Email Entries
From the WOW Mail application, this menu item (Email Setup > Work with Email Entries) lets you define an email template to be used for sending email:

Control Settings
- Unique Email ID – Unique record ID, set by WOW.
- Corresponding Control Record – The email control entry that is used to send this email.


Other Email Settings
- From ID – The email “From ID” used when the email is sent.
- Subject – The email “Subject”. The title can contain text, html, and WOW replacement variables.
- Content – The email content. The content can contain text, html, and WOW replacement variables.
- Bounce Email ID - Bounce email address to use if the email send fails.
- Tracking Option - Designates whether the sending of this email is logged. Entries are logged in the EMAILLOG table. Options as None (default), All, Success Only, Failure Only. These log entries can be viewed by running: Other > Work with Email Send Log Entries
Note: Replacement variables apply only when a “To ID” operation is specified or this email entry is a confirmation email. There must be a corresponding Row from which replacement variables can locate a substitution value. In the above example, the current value for field “firstname” is used as well as the value from the field "eventid".

Email Recipients
- ‘To ID’ Operation – Designates an operation to use to determine the To ID’s to receive this email. A separate email is sent each email ID returned from this operation. One of fields in the To ID operation must have it’s field descriptor usage ID set to -40 (email usage ID value). This value is ignored if the email entry is used for a confirmation email.
- To ID – Set this value when a only specific email ID is needed for this email entry. This value is ignored if the email entry is used for a confirmation email.
- Cc ID – The Cc ID used when an email is sent. The Cc ID only receives one copy of the email, when one or more email are sent from this operation.
- Bcc ID - The Bcc ID used when an email is sent. The Bcc ID only receives one copy of the email, when one or more email are sent from this operation.

Confirmation Email Settings
- File Name – Designates which file this email entry corresponds to and only applies to confirmation email.
- Library Name – Designates which library this email entry corresponds to and only applies to confirmation email.
- Connection Alias – Designates which connection this email entry corresponds to and only applies to confirmation email.
Note: If an operation is defined to send a confirmation email, WOW looks for a matching entry in the email entries defined. A match requires that the file, library and connection name for the operation be the same as the above three values (not these values specifically but the 3 values that reference your own information). If a match is not found, a default email is sent using the default email control entry.
Configuring Auto Send Email
Auto send email is an email that is sent automatically on a set schedule. To configure an auto send email, complete the following steps:
- Create an “Email Sender Batch” operation in the Outgoing Email application.
- Set the Operation Type to => Auto-Run Batch Process
- Replace the Operation Properties with an AutoRun property group similar to the following:
AutoRun {/* The date the batch auto run should start. format = MM/dd/yyyy */startDate:9/01/2005;/* The time the batch auto run should start. format = hh:mm a */startTime:3:00 pm;/* How often the batch auto run should execute (in seconds). 900 seconds = 15 minutes, 86400 = 1day, 604800 = 7 days */frequency:86400;}
- Set the operation’s Auto Run status to => Enabled
- Create an “Email Sender Control” operation in the Outgoing Email application:
- Leave the Operation Type as => SQL
- Set the operation code as => SELECT * FROM WOWMAIL64.EMAILCNTRL WHERE ACTIVE='Y'
- Set the Row Collection Class as planetj.dataengine.email.EmailSenderRowCollection
- Set email drop down for auto-run.
- Start the Outgoing Email operation.
- Use the “Email Control Entries” operation to create an Email Control entry (defines the SMTP email server settings used for sending the email). Ensure that the “Auto send is active for this entry” field is checked. See the “Email Control Entry Fields” section for more details.
- Use the “Email Entries” operation to create an Email entry (defines the email to be sent to each recipient). Ensure that the “Corresponding Control Record in the Control File” field is set to the control entry from the previous step. See the “Email Entry Fields” section above for more details.
- Change your WOW application’s web.xml file so that the PJ_AUTO_RUN parameter is set to true.
- Restart Tomcat or your application.
Configuring Manual Send Email
Manual send email is an “Email Entry” that is sent manually using the send email icon
(to the left of the email entry) from the “Manage Email Entries” screen. To configure a manual send email, complete the following steps:
- If an appropriate entry does not already exist, use the “Email Control Entries” operation to create an Email Control entry (defines the SMTP email server settings used for sending the email). See the “Email Control Entry Fields” section for more details.
- Use the “Email Entries” operation to create an Email entry (defines the email to be manually sent to each recipient). Ensure that the “Corresponding Control Record in the Control File” field is set to the control entry from the previous step. See the “Email Entry Fields” section for more details.
- To send the email, click on the manual email send icon
to the left of this email entry (this sends the email to the To ID or To ID Operation recipients).
Configuring Confirmation Send Email
Confirmation send email is an email entry that is sent automatically when an operation is run to perform an update or insert. The email is sent to the email ID included with the confirmation email operation. To configure a confirmation send email, complete the following steps:
- Create a Confirmation Send Operation. The operation can be created in any application, not just the Outgoing Email application.
- Set the Operation Code and Display Attributes (Allow Insert, Allow Updates) to allow for an update or insert into the file that will trigger the confirmation email. The Operation Code must include an email field, which will be the recipient of the confirmation email after the completion of the insert or update. An email field is a character type field with its Usage ID set to -40 (in the field’s Field Descriptor).
- In the Advanced section, set the row class to one of the following:
- planetj.dataengine.email.EmailConfirmationRow (both insert and update)
- planetj.dataengine.email.EmailInsertOnlyConfirmationRow
- planetj.dataengine.email.EmailUpdateOnlyConfirmationRow
Use the appropriate class file, depending on whether you want a confirmation email sent on an insert, update or both.
- If an appropriate entry does not already exist, use the “Email Control Entries” operation to create an Email Control entry (defines the SMTP email server settings used for sending the email). See the “Email Control Entry Fields” section for more details.
- Use the “Email Entries” operation to create an Email entry (defines the confirmation email to be sent to each recipient).
- Ensure that the “Corresponding Control Record in the Control File” field is set to the control entry from the previous step.
- Set the Confirmation Email Settings (File, Library, Connection) to correspond with the Confirmation Send operation in step 1 (the file and library from the operation’s “Operation Code” field and the connection used in the operation’s “Connection Alias” field).
- See the “Email Entry Fields” section for more details.
- Running the Confirmation Send Email operation should now trigger an email to be sent once the update and/or insert are complete.
Note: A Confirmation Send operation can reside in any application, as long as there is a corresponding entry (with the correct table, library and connection) in the EMAILLOG file.
SendEmail API
The newest addition to our WOW Email Add-on is the SendEmail api. This class allows the user to send email using HTML based email or the results of a WOW operation. The SendEmail api can be invoked by using a URL call or a direct class call. There are 4 different methods to use the SendEmail api. These will be described in depth below:
URL Call
SendEmail can be invoked with a simple URL call. The two methods are as follows:
Using SendEmail to Send a Pre-configured Email Entry
SendEmail can be used to send a pre-configured email entry (see section Email Entries) via a URL. Here is an example of using a URL to invoke SendEmail utilizing an email entry:
www.mycompany.com/wow65/run?PJMRCLASS=planetj.dataengine.email.SendEmail&emailId=5&logSend=ALL
NOTE in the URL:
- ? - designates the start of the parameters.
- = - separates the parameter name from it's value.
- & - is used as a parameter separator.
- All parameters are case sensitive.
- The URL cannot contain any blanks. Use a '+' instead.
Supported URL Parameters (parameter names are case sensitive):
- PJMRCLASS – Specifies the Java class to be called. In this case, it must always be set as: PJMRCLASS=planetj.dataengine.email.SendEmail
- emailId – specifies the Email ID (numeric) assigned to the email entry (*required for this type of SendEmail call).
- emailFromId – let's the user override the From ID specified in the email entry.
- emailToId – let's the user override the To ID or To ID Operation specified in the email entry.
- emailCcId – let's the user override the CCID of the email.
- emailBccId – let's the user override the BCCID of the email.
- bounceId - let's the user override the bounce ID of the email.
- _pj_lib – allows the user to specify a different WOW user library. The default points to the same user library that the context is set to.
- emailLib - the library which contains the email control tables (IE... smtp, etc). This defaults to the WOW mail library/schema specified in a) the application or b) a config property.
- logSend - Overrides the tracking option. Determines whether each send is logged in table EMAILLOG (in the WOW Mail library). Possible values are NONE (default), ALL, SUCCESS,
FAILURE. SUCCESS and FAILURE refer to whether the email send was successful. These log entries can be viewed by running: Other > Work with Email Send Log Entries
Using SendEmail to Send an Email with the Content Generated from a WOW Operation
SendEmail can be used to send an email, with it's email content populated with the results from a WOW Operation via a URL. Here is an example of using a URL to invoke SendEmail from an operation:
www.mycompany.com/wow65/run?PJMRCLASS=planetj.dataengine.email.SendEmail&operation=325&emailConfig=8&emailToId=jcustomer@gmail.com
NOTE in the URL:
- ? - designates the start of the parameters.
- = - separates the parameter name from it's value.
- & - is used as a parameter separator.
- All parameters are case sensitive.
- The URL cannot contain any blanks. Use a '+' instead.
- Only operations of type SQL and HTML Code are supported.
- If the operation is an HTML Code operation and the user specifies the emailToIdOp parameter, you can use substitution parameters (e.g. ??fieldname) in the HTML Code operation (if the field exists in rows returned by the To ID Operation).
Supported URL Parameters (parameter names are case sensitive):
- PJMRCLASS – Specifies the Java class to be called. In this case, it must always be set as: PJMRCLASS=planetj.dataengine.email.SendEmail
- operation – specifies the operation ID of the operation to be used to generate the email content. Supported operation types are SQL, Association 1 to many, Execution Group, Association Execution Group, HTML Code, and HTML Code Association. If the operation is an association, the emailToIdOp must be specified to provide associated Rows to run with. The execution group operations can be used to include results from 1 or more operations. If the operation is an Execution Group operation and any of the children operations are an association operation, the operation type must be set to Association Execution Group.
- emailConfig – The email server configuration ID to be used. This identifies all of the email server information needed for sending the email. *This parameter is required.
- emailFromId – let's the user specify the From ID to be used for the email. If not specified, the From ID from the server configuration will be used. The from ID must be specified either as a parameter or in the configuration.
- emailToId – let's the user specify the recipient of the email. Either emailToId or emailToIdOp must be specified.
- emailToIdOp – let's the user specify the to ID operation to be used for email recipients. Either emailToId or emailToIdOp must be specified. If this parameter is specified, the ToID Row is used for parameter substitution on the operation title and instructions. If the "operation" parameter specifies an association operation, this field is required and is used for the associated Rows as well.
- emailCcId – let's the user specify the CCID of the email (*optional).
- emailBccId – let's the user specify the BCCID of the email (*optional).
- bounceId - let's the user specify the bounce ID of the email (*optional).
- _pj_lib – allows the user to specify a different user library. The default points to the same user library that the context is set to (*optional).
- emailLib - the library or schema which contains the email control tables (EMAILCNTRL). This defaults to the mail lib specified in a) the application or b) a config property.
- logSend - Determines whether each send is logged in table EMAILLOG (in the WOW Mail library). Possible values are NONE (default), ALL, SUCCESS,
FAILURE. SUCCESS and FAILURE refer to whether the email send was successful. These log entries can be viewed by running: Other > Work with Email Send Log Entries
Direct Java Class Call
For the next 2 methods, if you are utilizing a Java subclass, you can invoke the SendEmail API within your custom code.
Note: For any optional parameter, use null when non-applicable.
Sending an Email With the Email Content Generated from a WOW Operation
The SendEmail api can be used to send an email, with it's email content populated with the results from a WOW Operation. SendEmail is invoked as follows:
int count = 0;
try {
// SendEmail sendEmail = new SendEmail(379, null, null, null, null, null, new Integer(378), new Integer(1), "WOWMAIL65",
// "NONE"); /* Example that uses the default for most of the parameters. */
SendEmail sendEmail = new SendEmail(operation, toId, ccId, bccId, bounceId, fromId, new Integer(toIdOperation),
new Integer(configId), emailLibrary, logSend);
count = sendEmail.send();
}
catch (CMException cme) {
System.out.println("Error occurred sending email: " + cme.getMessage());
}
Note: Java 6 will let you specify an int value in place of an Integer value (for Integer parameters) and converts the value for you automatically.
Constructor Parameters:
- operation (int) – Specifies the operation ID of the operation to be used to generate the email content. Supported operation types are SQL, Association 1 to many, Execution Group, Association Execution Group, HTML Code, and HTML Code Association. If the operation is an association, the emailToIdOp must be specified to provide associated Rows to run with. The execution group operations can be used to include results from 1 or more operations. If the operation is an Execution Group operation and any of the children operations are an association operation, the operation type must be set to Association Execution Group. *Required
- toId (String) – let's the user override the To ID or To ID Operation specified in the email entry. Specify null to use the default value from the email server entry or from the toIdOperation.
- ccId (String) – let's the user override the CCID of the email. Specify null to use the default value from the email entry. Specify null to use the default value from the email server entry.
- bccId (String) – let's the user override the BCCID of the email. Specify null to use the default value from the email entry. Specify null to use the default value from the email server entry.
- bounceId (String) - let's the user override the bounce ID of the email. Specify null to use the default value from the email entry. Specify null to use the default value from the email server entry.
- fromId (String) – let's the user override the From ID specified in the email entry. Specify null to use the default value from the email entry. Specify null to use the default value from the email server entry.
- toIdOperation (Integer) – lets the user specify the To ID operation to be used for email recipients. Either toId or toIdOperation must be specified. If this parameter is specified (non-null), the ToID Row is used for parameter substitution (e.g. ??field1) on the operation title and instructions. For the toIdOperation rows, each Row must contain 1 email field (usage ID = -40). The email field would be used for the To ID. If the "operation" parameter specifies an association operation, this parameter is required and is used for the associated Rows as well. Specify null when not using this option.
- configId (Integer) – The email server configuration ID to be used. This identifies all of the email server information needed for sending the email. *Required
- emailLibrary (String) - the WOW Mail library containing the email table. Specify null to use the default value.
- logSend (String) - Determines whether each send is logged in table EMAILLOG (in the WOW Mail library). Possible values are NONE (default), ALL, SUCCESS,
FAILURE. SUCCESS and FAILURE refer to whether the email send was successful. These log entries can be viewed by running: Other > Work with Email Send Log Entries. Specify null to default to NONE.
Sending Email Using a Pre-configured Email Entry
The SendEmail api can be used to send a pre-configured email entry (see section Email Entries). SendEmail is invoked as follows:
int count = 0;
try {
// SendEmail sendEmail = new SendEmail(null, null, null, null, null, new Integer(emailId), "WOWMAIL65", null,
// null); /* Example that uses the default from the Email entry for most of the parameters. */
SendEmail sendEmail = new SendEmail(toId, ccId, bccId, bounceId, fromId, new Integer(emailId), emailLibrary, logSend,
parameterRow, new Integer(toIdOperation));
count = sendEmail.send();
}
catch (CMException cme) {
System.out.println("Error occurred sending email: " + cme.getMessage());
}
Note: Java 6 will let you specify an int value in place of an Integer value (for Integer parameters) and converts the value for you automatically.
Constructor Parameters:
- toId (String) – let's the user override the To ID or To ID Operation specified in the email entry. Specify null to use the default value from the email entry.
- ccId (String) – let's the user override the CCID of the email. Specify null to use the default value from the email entry.
- bccId (String) – let's the user override the BCCID of the email. Specify null to use the default value from the email entry.
- bounceId (String) - let's the user override the bounce ID of the email. Specify null to use the default value from the email entry.
- fromId (String) – let's the user override the From ID specified in the email entry. Specify null to use the default value from the email entry.
- emailId (Integer) – specifies the Email ID (numeric) assigned to the pre-configured email entry (*required for this type of SendEmail call).
- emailLibrary (String) - the WOW Mail library containing the email table. Specify null to use the default value from the email entry.
- logSend (String) - Overrides the tracking option. Determines whether each send is logged in table EMAILLOG (in the WOW Mail library). Possible values are NONE (default), ALL, SUCCESS,
FAILURE. SUCCESS and FAILURE refer to whether the email send was successful. These log entries can be viewed by running: Other > Work with Email Send Log Entries. Specify null to default to NONE. - parameterRow (Row) - Provides a parameter Row for substitution parameters (e.g. ??field1) specified in the email entry. Specify null to not provide a parameter Row.
- toIdOperation (Integer) – lets the user override (in the pre-defined email) the to ID operation to be used for email recipients. If this parameter is specified (non-null) any other toId options are ignored and the toIdOperation rows are used for parameter substitution (e.g. ??field1) on the operation title and instructions. For the toIdOperation rows, each Row must contain 1 email field (usage ID = -40). The email field is used for the email's ToID value. Specify null when not using this option.
Creating Automated Email with WOW SendEmail
You can use one of the scheduling tools (such as Windows Task Scheduler) available to invoke the SendEmail class (via a URL call) on a predetermined schedule. The scheduling tool must exist on a system that has access to the WOW server. Below is an example using the Windows Task Scheduler on a Windows based PC
(Note: steps may vary depending on the tool used):
Scheduling Tasks with runURL
WOW includes a utility program named "runURL", which can be used when running a scheduled task. The runURL program is located in the WEB-INF directory within your WOW installation. You can either run the program directly from the WEB-INF directory or copy the files runURL.bat and runURL.jar into a more convenient location. In our example, we copied those 2 files to the folder "C:\Program Files\wow".
From the task scheduler, create a new task:

- Make sure the user has sufficient authority to run the task
- For the trigger, set the run schedule. You may want to place a run time limit on the task, such as 30 minutes.
- For the actions:

- Action should be "Start a program"
- Set the programs to the bat file just created: "C:\Program Files\wow\runURL.bat"
- Set the arguments to the SendEmail URL, for example: "http://www.mycompany.com/wow66/run?PJMRCLASS=planetj.dataengine.email.SendEmail&emailId=5" Use double quotes around the URL.
- Start in: C:\Program Files\wow
- For Conditions, set as needed
- For Settings, use settings similar to the following:

Using the Results of a Row Collection as a Distribution List
By using a PlanetJ created Row Collection Class (planetj.dataengine.email.SendEmailRowCollection), you can use the results of an SQL operation to create a distribution list and email on-the-fly. In functional terms, this Row Collection Class adds a RowCollection action at the bottom of the screen that will cause the default emailer to pop-up a composition screen pre-filled with all the email addresses that could be extracted from the resulting RowCollection.
To set this up, first start by creating a SQL operation that returns email addresses in the Row Collection.
select * from pjdata.employeeIn this case, pjdata.employee contains a field named EMAIL which has a FD Usage Id of -40, which corresponds to an email field.

It also has its field class set to Email, as seen in the images below:

You will also want to set the Row Collection Class in the Operation to planetj.dataengine.email.SendEmailRowCollection as seen in the screenshot below:

Now, when you run the operation, a button will appear at the bottom of the Row Collection:

Once clicked, your default email program will open an email composition window. All the email addresses from the Row Collection will be included in the To: field as seen in the screenshot below:

NOTE: As you can see by the image above, Gmail can even be used to compose the email. In this case, the browser has Google Toolbar installed so the Gmail window opens.
NOTE: Since the "mailto" HTML (assigned to the button) must be generated when the RowCollection is rendered, row selection cannot be used to filter the list of email addresses, it must be done by filtering via SQL parameters.