This section has step-by-step instructions on how to implement and configure this example for use in your application. Before you start, please make sure that:
1) Copy the email files into your application directory:
<e-mail example>\emailDialog.html | into <application>\ |
<e-mail example>\emailSend.jsp | into <application>\ |
<e-mail example>\emailError.jsp | into <application>\ |
<e-mail example>\styles1.css | into <application>\ |
<e-mail example>\images\emailBlox.gif | into <application>\images\ |
<e-mail example>\images\required.gif | into <application>\images\ |
<e-mail example>\images\gridlogo-sm.gif | into <application>\images\ |
<e-mail example>\images\grid-bg.gif | into <application>\images\ |
<e-mail example>\WEB-INF\classes\alphablox\EMailBean.class | into <application>\WEB-INF\classes\alphablox\ |
<e-mail example>\WEB-INF\classes\alphablox\HTMLFileParser.class | into <application>\WEB-INF\classes\alphablox\ |
<e-mail example>\WEB-INF\classes\alphablox\HTMLFile.class | into <application>\WEB-INF\classes\alphablox\ |
<email example>\WEB-INF\lib\activation.jar |
into <application>\WEB-INF\lib\ |
<email example>\WEB-INF\lib\mail.jar | into <application>\WEB-INF\lib\ |
After you have moved the class files under your application's directory, you may need to restart the Alphablox server. See the Troubleshooting page for more information.
2) Create a file called 'emailTemplate.jsp' in your application directory. You can create your own or copy and modify the one that is included in the example. This file should contain the HTML that will appear in the generated eMail message. To include one or more of the Blox from the application, copy its <blox:display> tag and set its 'render' property to 'printer'. See the example emailTemplate.jsp file for more information.
3) Define the function openEmailDialog() in the application (copy and paste the following into your JSP page):
// Open the eMailWindow
function openEmailDialog() {
var height = 300;
var width = 440;
var top = (screen.height / 2) - (height / 2) - 100;
var left = (screen.width / 2) - (width / 2);
var features = "Height=" + height + ",Width=" + width + ",top=" + top + ",left=" + left;if (window.EmailWindow && window.EmailWindow.closed == false) {
window.EmailWindow.focus();
}
else {
EmailWindow = window.open("emailDialog.html","",features);
}
}
4) Add the emailBlox.gif image to the application, with code to ensure that clicking on this .gif file calls openEmailDialog() function:
<IMG SRC="images/emailBlox.gif" ALT="Send as Email" onClick="javascript:openEmailDialog()">