10 Steps to Configure Email – Websphere Commerce Server
10 Steps to Configure Email – Websphere Commerce Server
Websphere Commerce Server – Configure Email
Follow 10 steps for configuring email in Websphere Commerce
Server
Step 1: Create a JSP ( eg:- AbcEmailNotify.jsp)
Create a JSP, lets name it AbcEmailNotify.jsp
AbcEmailNotify.jsp will be used for displaying contents of email to recipient.
AbcEmailNotify.jsp will be used for displaying contents of email to recipient.
Note: Currently keep AbcEmailNotify.jsp as blank (without any
code)
Step 2: Create View ( eg- AbcEmailNotifyView)
Make an Entry in Struts-Config.xml file for
AbcEmailNotify.jsp as below
< action path=’/AbcEmailNotifyView’
type=’com.ibm.commerce.struts.BaseAction’>
< set-property property =’authenticate’ value =’10101:1′/>
< set-property property =’https’ value =’10101:1′/>
< /action>
< set-property property =’authenticate’ value =’10101:1′/>
< set-property property =’https’ value =’10101:1′/>
< /action>
< forward name=”AbcEmailNotifyView /10101/-3″ path=”/<
location of JSP file >/AbcEmailNotify.jsp”
className=”com.ibm.commerce.struts.ECActionForward”>
< set-property property=”implClassName” value=”com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl”/>
< set-property property=”interfaceName” value=”com.ibm.commerce.messaging.viewcommands.MessagingViewCommand”/>
< /forward>
< set-property property=”implClassName” value=”com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl”/>
< set-property property=”interfaceName” value=”com.ibm.commerce.messaging.viewcommands.MessagingViewCommand”/>
< /forward>
Step 3: Entry ViewName (AbcEmailNotifyView) in MSGTYPE table
Execute below SQL
INSERT INTO MSGTYPES(MSGTYPE_ID , MSGTDIR , NAME , VIEWNAME,
DESCRIPTION)
VALUES((SELECT MAX(MSGTYPE_ID)+1) FROM MSGTYPE) , 1, ‘< Name of MSG>’, ‘< View Name of JSP>’, ”)
VALUES((SELECT MAX(MSGTYPE_ID)+1) FROM MSGTYPE) , 1, ‘< Name of MSG>’, ‘< View Name of JSP>’, ”)
Example
INSERT INTO MSGTYPES(MSGTYPE_ID , MSGTDIR , NAME , VIEWNAME, DESCRIPTION)
VALUES((SELECT MAX(MSGTYPE_ID)+1) FROM MSGTYPE) , 1, ‘AbcEmailNotify’, ”AbcEmailNotifyView’, Testing Email ‘)
INSERT INTO MSGTYPES(MSGTYPE_ID , MSGTDIR , NAME , VIEWNAME, DESCRIPTION)
VALUES((SELECT MAX(MSGTYPE_ID)+1) FROM MSGTYPE) , 1, ‘AbcEmailNotify’, ”AbcEmailNotifyView’, Testing Email ‘)
Step 4: Create ACPLoad file for AbcEmailNotifyView
< Policies>
< Action Name=”AbcEmailNotifyView” CommandName=”AbcEmailNotifyView”>
< /Action>
< ActionGroup Name=”AllSiteUsersViews” OwnerID=”RootOrganization”>
< ActionGroupAction Name=”AbcEmailNotifyView”/>
< /Policies>
< Action Name=”AbcEmailNotifyView” CommandName=”AbcEmailNotifyView”>
< /Action>
< ActionGroup Name=”AllSiteUsersViews” OwnerID=”RootOrganization”>
< ActionGroupAction Name=”AbcEmailNotifyView”/>
< /Policies>
Step 5: Run ACPLaod for AbcEmailNotifyView
Step 6: Configure Email Transport Type
Open WCS Administrative Console
Site -> Configuration -> Transport
select “Email”
Click Active (if it is inactive)
Now again select Email
Click on Configure
Enter Host ( Contact admin team )
Enter protocol (by default smtp, leave as it is)
Enter port ( by default 25, leave as it is)
Click “Ok”
Step 7: Entry in PROFILE Table
Open WCS Administrative Console
Site -> Configuration -> Message Type ->New
Select Message Type from Drop Down (Display entries of MSGTYPE table )
Transport Type – Email ( from Drop Down)
Device Format — Standard Device Format
Click Next
Finish
Step 6: Configure Email Transport Type
Open WCS Administrative Console
Site -> Configuration -> Transport
select “Email”
Click Active (if it is inactive)
Now again select Email
Click on Configure
Enter Host ( Contact admin team )
Enter protocol (by default smtp, leave as it is)
Enter port ( by default 25, leave as it is)
Click “Ok”
Step 7: Entry in PROFILE Table
Open WCS Administrative Console
Site -> Configuration -> Message Type ->New
Select Message Type from Drop Down (Display entries of MSGTYPE table )
Transport Type – Email ( from Drop Down)
Device Format — Standard Device Format
Click Next
Finish
Note:- This will do an entry in PROFILE table corresponding
to MSGTYPE_ID which we entered in MSGTYPE table.
Step 8: Create a method to send email
public void sendEmail() throws ECException {
SendMsgCmd sendMsgCmd;
try {
sendMsgCmd = (SendMsgCmd) CommandFactory.createCommand(SendMsgCmd.NAME, getCommandContext().getStoreId());
//’AbcEmailNotify’ – entry in MSGTYPE table
sendMsgCmd.setMsgType(“AbcEmailNotify”);
SendMsgCmd sendMsgCmd;
try {
sendMsgCmd = (SendMsgCmd) CommandFactory.createCommand(SendMsgCmd.NAME, getCommandContext().getStoreId());
//’AbcEmailNotify’ – entry in MSGTYPE table
sendMsgCmd.setMsgType(“AbcEmailNotify”);
sendMsgCmd.setStoreID(getCommandContext().getStoreId());
sendMsgCmd.setCommandContext(getCommandContext());
sendMsgCmd.setConfigData(“subject”, “This is test email”);
sendMsgCmd.setCommandContext(getCommandContext());
sendMsgCmd.setConfigData(“subject”, “This is test email”);
//abc@abc.com – email to whom you want to send email
sendMsgCmd.setConfigData(“recipient”, “abc@abc.com”);
sendMsgCmd.setConfigData(“contentType”, “text/html”);
sendMsgCmd.setConfigData(“recipient”, “abc@abc.com”);
sendMsgCmd.setConfigData(“contentType”, “text/html”);
//Set parameter which you want todisplay recipient
final TypedProperty property = new TypedProperty();
property.put(“FirstName”,”Shailendra”);
property.put(“LastName”,”Mishra”);
property.put(“Address”,”Shahdol”);
final TypedProperty property = new TypedProperty();
property.put(“FirstName”,”Shailendra”);
property.put(“LastName”,”Mishra”);
property.put(“Address”,”Shahdol”);
sendMsgCmd.compose(“AbcEmailNotifyView”, getCommandContext(),
property);
sendMsgCmd.sendImmediate();
sendMsgCmd.execute();
} catch (Exception exception) {}
}
sendMsgCmd.sendImmediate();
sendMsgCmd.execute();
} catch (Exception exception) {}
}
Step 9 : Call sendEmail() method for sending email
Call sendEmail() for triggering email, this method can be
called at any place of your controller command whereever you want to send
email.
Example:- Let say if you want to trigger a email to user who has place an order. Please see code sample for same
Example:- Let say if you want to trigger a email to user who has place an order. Please see code sample for same
Class ExOrderProcessCmdImpl extends OrderProcessCmdImpl{
Public void performExecute(){
Super.performExecute();
sendEmail();
}
}
Note: – In this case sendEmail() method should defined in ExOrderProcessCmdImpl. In other words, method sendEmail() mentioned above in step 8 should present in class ExOrderProcessCmdImpl
Public void performExecute(){
Super.performExecute();
sendEmail();
}
}
Note: – In this case sendEmail() method should defined in ExOrderProcessCmdImpl. In other words, method sendEmail() mentioned above in step 8 should present in class ExOrderProcessCmdImpl
Step 10: Content of AbcEmailNotify.jsp
Modify your AbcEmailNotify.jsp as per you requirement and
template, otherwise email will be sent to customer without any body/content,
but subject line will be there which you have written in step 8.
sendMsgCmd.setConfigData(“subject”, “This is test email”);
Comments
SQL had a couple of typos tho'
INSERT INTO MSGTYPES(MSGTYPE_ID , MSGTDIR , NAME , VIEWNAME, DESCRIPTION) VALUES((SELECT (MAX(MSGTYPE_ID)+1) FROM MSGTYPES) , 1, 'AbcEmailNotify', 'AbcEmailNotifyView', 'Testing Email ')