Skip to main content

How to do Email Configurations in Web sphere Commerce

Web sphere commerce allows to send email messages to customers by making use of the below mentioned steps.

Create the JSP which will be used for generating contents of the email 

For e.g.: SendEmail.jsp

Create View for the JSP in Struts-Config-Ext.xml

Make an Entry in Struts-Config-Ext.xml file for .jsp as below

< action path='/SendEmailView' type='com.ibm.commerce.struts.BaseAction'>
    < set-property property ='authenticate' value ='10001:1'/>
     < set-property property ='https' value ='10001:1'/>
< /action>

< forward name="SendEmailView /10001/-3" path="/< location of JSP file >/ TestEmail.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>

Make an entry in MSGTYPE table for the view name

MSGTYPE   Table: This table is used by the messaging system to store header information about the available message types.

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>', '')

INSERT INTO MSGTYPES(MSGTYPE_ID , MSGTDIR , NAME , VIEWNAME, DESCRIPTION)
VALUES((SELECT MAX(MSGTYPE_ID)+1) FROM MSGTYPE) , 1, 'SendEmail',’ SendEmailView’, 'Send Email ')

Create and run ACPLoad file for SendEmailNotifyView

< Policies>
< Action Name=" SendEmailView’" CommandName=" SendEmailView’">
< /Action>
< ActionGroup Name="AllSiteUsersViews" OwnerID="RootOrganization">
< ActionGroupAction Name=" SendEmailView’"/>
< /Policies>

Configure Email Transport Type in IBM WCS Admin Console

1    Open WCS Administrative Console go to  Site -> Configuration -> Transport.
2    Select "Email” Click Active (if it is inactive).
3    Select Email once again and click on Configure.
4    Enter Host, Enter protocol (by default SMTP, leave as it is),Enter port ( by default it will be 25) and Click "Ok"

Make an Entry in PROFILE Table for the message type

PROFILE Table: This table is used by the messaging system to store profile data. Specifically, it defines what transports are to be used for particular stores, message types, and priorities. It also holds other administrative information

1.      Open WCS Administrative Console go to Site -> Configuration -> Message Type
2.      Select Message Type from Drop Down (Display entries of MSGTYPE table )
3.      Select Transport Type - Email  from Drop Down
4.      Select Device Format  as  Standard Device Format  and Finish

Note: - This will do an entry in PROFILE table corresponding to MSGTYPE_ID which we entered in MSGTYPE table.

Use OOB  SendMsgCmd to  send email

SendMsgCmd command is having two methods of sending messages.
  •                      sendImmediate() 
  •                      sendTransacted()

public void sendImmediate():

This method sends the message immediately to recipients. The caller is blocked until the message has been sent. This method sets the sending mode to send the message and wait for a reply.

public void sendTransacted():

This method stores the message in the MSGSTORE database table. At a predetermined time, the WebSphere Commerce scheduler invokes a job that sends all messages stored in batch mode. Using this method ensures that a send occurs only after the caller has committed or terminated successfully. This method should be used if blocking a call using the sendImmediate() method cannot be tolerated.

SendMsgCmd sendMsgCmd;
try {
sendMsgCmd = (SendMsgCmd) CommandFactory.createCommand(SendMsgCmd.NAME,
getCommandContext().getStoreId());
sendMsgCmd.setMsgType("'SendEmail'");
//MSGTYPE Table entry.That is MSGTYPES.NAME column
sendMsgCmd.setStoreID(getCommandContext().getStoreId());
sendMsgCmd.setCommandContext(getCommandContext());
sendMsgCmd.setConfigData("subject", "Send email");
sendMsgCmd.setConfigData("recipient", "wcshintsandtips@gmail.com");
sendMsgCmd.setConfigData("contentType", "text/html");
final TypedProperty property = new TypedProperty();
property.put("FirstName"," WCS");
property.put("LastName","Tips");
property.put("Address","Bangalore");
//Struts Entry . That is MSGTYPES. VIEWNAME column
sendMsgCmd.compose("SendEmailView’", getCommandContext(), property);
sendMsgCmd.sendImmediate();
sendMsgCmd.execute();
} catch (Exception e) {}
}


Comments

Popular posts from this blog

How to read applied promotions codes

The below snippet will give you to read the promotions codes which are applied to order number, String orderId = "978593958"; OrderKey orderKey = new OrderKey(new Long(orderId)); PromotionArgumentSessionBeanPersistenceManager promoManager = new PromotionArgumentSessionBeanPersistenceManager(); PromotionArgument promArg = promoManager.load(orderKey); Iterator prmoExeRecds = promArg.getPromotionExecutionRecords(); while(prmoExeRecds.hasNext()) { PromotionExecutionRecord promotionExeecutionRecord = (PromotionExecutionRecord) prmoExeRecds.next(); Promotion promotion = promotionExeecutionRecord.getPromotion(); System.out.println("Name: " + promotion.getName()); System.out.println("Admin description: " + promotion.getDescription(commandContext.getLocale(), com.ibm.commerce.marketing.promotion.Description.SHOPPER_SHORT_DESC)); }

IBM Announces version 9 of WebSphere Commerce!

What’s new in Version 9 includes information about new functionality and changes in existing functionality from previous WebSphere Commerce Version to the modernized WebSphere Commerce Version 9 release: Micro services architecture , with lightweight, self-contained, distributed servers, supports horizontal scaling, parallel development, and utilization of modern, open source tools. Docker containers deliver key benefits for DevOps , including deployment automation, delivery acceleration, and application portability. Flexible deployment options for  Docker containers  gives IT organizations more infrastructure choices for e-commerce workloads, including all cloud options: private, public, or hybrid deployment. Evolution of the technology stacks  makes customization of the brand and business user experience more efficient and cost effective. Key changes include adoption of lightweight IBM WebSphere Liberty, replacement of Enterprise JavaBeans™ (EJBs) with Java™ Pers...