邮件中如何写html

删除回忆录丶 提交于 2019-12-08 00:53:16

 StringBuilder stringBuilder = new StringBuilder();利用StringBuild对象

将写好样式的表单或者表格用append方法添加,最后用stringBuilder.toString()方法即可转为实际页面

注意将所有值的空格全部替换成" "否则,有空格的值无法读取完整信息。

 stringBuilder.append(
"<body style=\"background:#CEFFCE\">\n"+
        "<form>\n"+
            "<div style=\"text-align:right\">\n"+
                "<label  style=\"font-family:微软雅黑;font-size:13px\">Date Reported:</label><input type=\"text\"  style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("RPT_DTE")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Your Name:</label><input type=\"text\"  style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("RPT_NAM")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Your Department:</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("RPT_DPT")).replace(" ", "&nbsp;")+"><br/>\n"+
            "</div>\n"+
        "</form>\n"+
        "<hr />\n"+
        "<p style=\"text-align:center;font-weight:bold\" >Transaction Details</p>\n"+
        "<hr />    \n"+
        "<form>\n"+
            "<div style=\"text-align:right\">\n"+
                "<label  style=\"font-family:微软雅黑;font-size:13px\">Transaction Reference:</label><input type=\"text\"  style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("TRANS_REF")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Currency:</label><input type=\"text\"  style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("CURRENCY")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Transaction Amount(FCY):</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("AMOUNT_FCY")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label  style=\"font-family:微软雅黑;font-size:13px\">Transaction Amount(LCY):</label><input type=\"text\"  style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("AMOUNT_LCY")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Value Date of Transaction:</label><input type=\"text\"  style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("VALUE_DATE")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">What bank are we are receiving the funds from?</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("FRM_BAK")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">What country are the funds coming from?</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("FRM_CTY")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">What bank are we paying the funds to?</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("PAY_BAK")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">What country are we paying the funds to?</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("PAY_CTY")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Name of the Remitter:</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("RMT_NAM")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Name of the Beneficiary:</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("BFY_NAM")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Do you suspect that Money Laundering has already taken place?<label/>");
                 if(spcLdr){
                      stringBuilder.append(STYLE_CHECKED);
                 }else{
                     stringBuilder.append(STYLE_NOCHECKED);
                 }
                 stringBuilder.append("<label style=\"font-family:微软雅黑;font-size:13px\">Do you think that this transaction is money laundering or terrorist financing in action?<label/>");
                 if(spcFnc){
                     stringBuilder.append(STYLE_CHECKED);
                }else{
                    stringBuilder.append(STYLE_NOCHECKED);
                }
                 stringBuilder.append("<label style=\"font-family:微软雅黑;font-size:13px\">Are you asking for the consent ot the MLRO to undertake the transaction?<label/>");
                 if(spcUtk){
                    stringBuilder.append(STYLE_CHECKED);
                 }else{
                   stringBuilder.append(STYLE_NOCHECKED);
                 }
                 stringBuilder.append(
             "</div>\n"+
        "</form>\n"+
        "<hr />\n"+
        "<div style=\"text-align:right\">\n"+
            "<label  style=\"font-family:微软雅黑;font-size:13px\">Explain why are you Suspicious about this transaction?</label><br/>\n"+
            "<textarea  style=\"width:939px;height:100px;margin:3px 0px 3px 0px\">"+((String)param.get("RPT_DCP")).replace(" ", "&nbsp;")+"</textarea><br/>\n"+
        "</div>\n"+
        "<hr />\n"+
"</body>"
                 );

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!