Encoding for e-mail transmission

For e-mail transmissions where the content must be encoded, the various messaging commands choose the encoding based on the following hierarchy:

About this task

  • If the member_ID is specified
  • If the member_ID is not specified

The outbound messaging task command (SendMsgCmd) uses the messaging system object (Messaging) to create and send messages. The encoding selection hierarchy depends on whether the messaging task command specifies a Member_ID (CmdSendMsg.addMember(getUserID) or not.

  • If the member_ID is specified
    Determine the proper encoding:
    • Use the user's preferred language to determine the proper encoding. The UserAccessBean.getPreferredLanguageId retrieves the LANGUAGE_ID column of the USERS table, which provides the user's preferred language.
    • If the user does not have language preference, use the default language of the store to determine the proper encoding. The StoreAccessBean.getLanguageId retrieves the LANGUAGE_ID column of the STORE table, which provides the default language of the store. The following is an example of how to do this:
      
      ...
      <c:set var="preferredLanguage"
      value="${WCParam.usr_preferredLanguage}"/>
      <c:if test="${empty preferredLanguage}">
      <c:set var="preferredLanguage"
      value="${CommandContext.languageId}"/>
      </c:if> 
      ...
      
  • If the member_ID is not specified

    Use the site default language. The messaging system object (Messaging) sets the preferred language to "DefaultLang" which gets replaced with the site default language by the E-mail adapter's code.

    The outbound messaging system uses JavaServer page composition templates for a number of message types (see the product documentation for more information about this topic).

  • Globalization enabled e-mail messaging

    When a message of one of these types is generated within HCL Commerce, the message composition service uses the corresponding template to create the outbound message. Once it is created, the outbound message can be sent through whatever transports have been assigned to the message type in the Administration Console.

Procedure

To illustrate the concept of JSP composition template and the various globalization capabilities of the outbound messaging system, the following is an end-to-end example about how to implement a globalization enabled e-mail messaging command:
  1. Initialize com.ibm.commerce.messaging.commands.SendMsgCmd in your command implementation in order to create a message:
    
    com.ibm.commerce.messaging.commands.SendMsgCmd sendMsgCmd =
    (com.ibm.commerce.messaging.commands.SendMsgCmd)
    CommandFactory.createCommand(SendMsgCmd.NAME, getStoreId());
    

    The getStoresJS method creates a JavaScript array with all information entitled to the user according to the access control policy. The information includes the stores that the user is entitled to access, the fulfillment centers of those stores, and the languages supported by each of the stores. The following is an example of a JavaScript array created by a call to the getStoresJS method:

  2. Retrieve the translated subject of the message:
    
    Locale locale = getCommandContext().getLocale();
    ResourceBundle property = (ResourceBundle)
    ResourceBundle.getBundle("yourPropertyFile", locale);
    String subject = property.getString("SUBJECT_CONTENT");
    
  3. Pass in the translated subject line with the setConfigData method defined in SendMsgCmd:
    
    sendMsgCmd.setConfigData("subject", subject);
    
  4. Retrieve the translated content of the message:
    
    // assume you are using storeId 1
    sendMsgCmd.setStoreID(new Integer(1));
    // the default Message Type ID for Password Reset Notification view
    name is "PasswordNotify" (that is MSGTYPES.NAME).
    sendMsgcmd.setMsgType("PasswordNofity");
    // pass the viewName, commandContext and TypedProperty to compose
    the
    message
    // the default MSGTYPES.VIEWNAME of Password Reset Notification is
    PasswordNotifyView. If null is specified, the default view name
    will be used. A different view name can be specified.
    sendMsgCmd.compose("PasswordNotifyView", getCommandContext(),
    typedProperty);
    
  5. Create the view JSP of your command as follows:
    1. Retrieve the locale as shown in the following:
      
      ...
      <c:set var="localeOwn" value="${CommandContext.locale}"/>
      ...
      <html>
      ...
      ...
      <param name="LOCALE" value="${localeOwn}"/>
      ...
      ...
      </html>
      
      
    2. Retrieve the corresponding properties file and get the translated text to generate the content of the message:
      
      ...
      <c:set var="locale" value="${CommandContext.locale}"/>
      ...
      <fmt:setLocale value="${CommandContext.locale}" />
      <fmt:setBundle basename="${path}PasswordResetNotification"
      var="bnResourceBundle" />
      ...
      ...
      <title><fmt:message key="eMarketingSpot_UpSellCrossSell"
      bundle="${bnResourceBundle}"/></title>
      
      

Results

The JSP associated with your view command generates the globalization enabled message to be delivered to the outbound messaging queue (temporarily stored in MSGSTORE table).

The following table shows examples of message types that use message composition templates. You can use these templates and their associated commands as a reference when building your own messaging commands and composition templates.

Message type JSP template Path
OrderCreateXMLFormat OrderCreateXML.jsp workspace_dir\Stores\Web Content
OrderStatusNotify OrderStatusNotify.jsp workspace_dir\Stores\Web Content
PasswordReset PasswordResetNotification .jsp workspace_dir\Stores\Web Content
  • The default name of a JSP template is registered in the struts-config.xml file for HCL Commerce Version 9.0.0.x. For Version 9.0.x, it is registered in the struts-wcs-stores.xml file. Newly customized entries should be added to the struts-config-ext.xml file of the Stores.war for 9.0.0.x, and struts-wcs-stores-custom.xml of the Stores.war for 9.0.x. By design, the Inbound Messaging System in HCL Commerce outputs all messages (for transports such as file and MQ) in UTF-8 format. This is to allow for easy communications, since UTF-8 has become the standard computer-to-computer communication character encoding.
  • HCL Commerce supports only UTF-8 encoding for message composition. If you encounter any issues regarding special characters that are not displaying correctly due to encoding issues, see .