首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

WCS 配备邮件消息发送

2013-03-21 
WCS 配置邮件消息发送step 1, active the E-mail Transports in Admin Console,??step 2, configure a mes

WCS 配置邮件消息发送

step 1, active the E-mail Transports in Admin Console,

?WCS 配备邮件消息发送
?

step 2, configure a message type and make it a record in the profile table,

insert into msgtypes(msgtype_id,msgtdir,name,viewname,description) values((select max(msgtype_id)+1 from msgtypes),1,'EmailToFriend','EmailToFriendView','Email Content to a friend about what you want to recommand');
insert into profile(profile_id,store_id,devicefmt_id,transport_id,msgtype_id,usersview,lowpriority,highpriority,archivemsg) values((select min(profile_id)-1 from profile),0,-3,1,(select max(msgtype_id) from msgtypes),'N',0,3,0);

step 3, configure the struts,(here the forward jsp can be changed to a specific format jsp)

<forward className="com.ibm.commerce.struts.ECActionForward" name="EmailToFriendView/10151/-3" path="/Test/TestOutput.jsp">
<set-property property="implClassName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl"/>
<set-property property="interfaceName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommand"/>
</forward>

<action path="/EmailToFriendView" type="com.ibm.commerce.struts.BaseAction">
</action>

step 4, Configure the access control for EmailToFriendView

insert into acaction ( acaction_id, action) values ( (select min(acaction_id) - 1 from acaction),? 'EmailToFriendView');
insert into acactactgp (acaction_id, acactgrp_id) values ( (select acaction_id from acaction where action = 'EmailToFriendView'), (select acactgrp_id from acactgrp where groupname = 'AllSiteUsersViews'));

?

step 5, Customize SendEmailCmd to record data in msgstore table.

?

接口:

package com.petco.commerce.endeca.commands;

import com.ibm.commerce.command.ControllerCommand;

public interface SendEmailCmd extends ControllerCommand {
?public static final String CLASSNAME = SendEmailCmd.class.getName();
?static final String defaultCommandClassName= CLASSNAME+"Impl";
?
?public void setMsgName(String msgName);
?public void setEmail(String email);
?public void setSubject(String subject);
?public void setSender(String sender);
}

?

实现类:

?

package com.petco.commerce.endeca.commands;

import com.ibm.commerce.command.CommandContext;
import com.ibm.commerce.command.ControllerCommandImpl;
import com.ibm.commerce.datatype.TypedProperty;
import com.ibm.commerce.exception.ECException;
import com.ibm.commerce.messaging.outboundservice.Messaging;
import com.ibm.commerce.ras.ECTrace;
import com.ibm.commerce.ras.ECTraceIdentifiers;

public class SendEmailCmdImpl extends ControllerCommandImpl implements
??SendEmailCmd {

?private String msgName;
?
?private String email;
?
?private String subject ;
?
?private String sender ;
?
?
?

?@Override
?public boolean isGeneric() {
??// TODO Auto-generated method stub
??return super.isGeneric();
?}

?@Override
?public void setRequestProperties(TypedProperty reqProperties)
???throws ECException {
??// TODO Auto-generated method stub
??super.setRequestProperties(reqProperties);
?}

?@Override
?public void performExecute() throws ECException {
??// TODO Auto-generated method stub
??super.performExecute();
??String methodName = "performExecute";
??????? ECTrace.entry(ECTraceIdentifiers.COMPONENT_EXTERN, this.getClass()
??????????????? .getName(), methodName);
??//Test code segment begin
//??String email = "TestEmailContent";
//??String userId = "-1000";
//???????? CommandContext cmdClone = (CommandContext) getCommandContext().clone();
//???????? cmdClone.setLanguage(getCommandContext().getLanguage());
//???????? cmdClone.setLanguageId(getCommandContext().getLanguageId());
//???????? cmdClone.setLocale(getCommandContext().getLocale());
//???????? cmdClone.setStoreId(getStoreId());
//???????? Messaging m = new Messaging("EmailToFriend", getStoreId());
//???????? m.setConfigData("subject", "Email to friend");
//???????? m.setConfigData("sender", "");
//???????? m.setConfigData("recipient", email);
//
//???????? TypedProperty prop = new TypedProperty();
//???????? prop.put("userId", userId);
//???????? prop.put("email",email);
//???????? m.compose(null, cmdClone, prop);
//???????? m.sendTransacted();
????? //Test code segment end?
??????? //Real code segment begin
???????? CommandContext cmdClone = (CommandContext) getCommandContext().clone();
???????? cmdClone.setLanguage(getCommandContext().getLanguage());
???????? cmdClone.setLanguageId(getCommandContext().getLanguageId());
???????? cmdClone.setLocale(getCommandContext().getLocale());
???????? cmdClone.setStoreId(getStoreId());
???????? Messaging m = new Messaging(getMsgName(), getStoreId());
???????? m.setConfigData("subject", getSubject());
???????? m.setConfigData("sender", getSender());
???????? m.setConfigData("recipient", getEmail());

???????? TypedProperty prop = new TypedProperty();
???????? prop.put("userId", getCommandContext().getUserId());
???????? prop.put("email",getEmail());
???????? m.compose(null, cmdClone, prop);
???????? m.sendTransacted();
???????? //Real code segment end??
????????
???????? ECTrace.exit(ECTraceIdentifiers.COMPONENT_EXTERN, this.getClass()
???????????????? .getName(), methodName);
??
?}

?@Override
?public void validateParameters() throws ECException {
??// TODO Auto-generated method stub
??super.validateParameters();
?}

?public String getMsgName() {
??return msgName;
?}

?public void setMsgName(String msgName) {
??this.msgName = msgName;
?}

?public String getEmail() {
??return email;
?}

?public void setEmail(String email) {
??this.email = email;
?}

?public String getSubject() {
??return subject;
?}

?public void setSubject(String subject) {
??this.subject = subject;
?}

?public String getSender() {
??return sender;
?}

?public void setSender(String sender) {
??this.sender = sender;
?}

}

热点排行