private String updateOutboundTemplateString(String template, OutboundMessage msg) throws UnsupportedEncodingException
{
ExtStringBuilder sb = new ExtStringBuilder(template);
sb.replaceAll("%gatewayId%", URLEncoder.encode(msg.getGatewayId(), getProperty("encoding", "ISO-8859-1")));
sb.replaceAll("%encoding%", (msg.getEncoding() == MessageEncodings.ENC7BIT ? "7-bit" : (msg.getEncoding() == MessageEncodings.ENC8BIT ? "8-bit" : "UCS2 (Unicode)")));
if(msg.getDate() != null) sb.replaceAll("%date%", URLEncoder.encode(msg.getDate().toString(), getProperty("encoding", "ISO-8859-1")));
sb.replaceAll("%text%", URLEncoder.encode(msg.getText(), getProperty("encoding", "ISO-8859-1")));
sb.replaceAll("%refNo%", URLEncoder.encode(msg.getRefNo(), getProperty("encoding", "ISO-8859-1")));
sb.replaceAll("%recipient%", msg.getRecipient());
sb.replaceAll("%from%", msg.getFrom());
sb.replaceAll("%failureCause%", URLEncoder.encode(msg.getFailureCause().toString(), getProperty("encoding", "ISO-8859-1")));