发送newsletter

public ActionForward doSendTestEmail(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
{
DynaActionForm productForm = (DynaActionForm) form;
Newsletter newsLetter = (Newsletter) productForm.get("newsletter");
String newsletterId = request.getParameter("newsletterId");
newsLetter.setNewsLetterId(new Long(newsletterId));
//根据id取得相应的newsletter的信息
newsLetter = super.getService().getNewsletterService().doLoadNewsletter(newsletterId);
String fileName = newsLetter.getFileName();
String saveFileName = newsLetter.getSavefileName();

//从资源文件取出存放的位置
Properties properties = UtilProperties.getProperties("upload.properties");
String savePath = properties.getProperty("resourcePath");
//获取附件rul地址信息
Properties propertiesUrl = UtilProperties.getProperties("url.properties");
String urlPath = propertiesUrl.getProperty("newsletterUrl");
String newsletterPath =
savePath
+ File.separator
+ "newsletter"
+ File.separator
+ saveFileName
+ File.separator
+ fileName
+ File.separator
+ "index.htm";
//同时支持html格式的文件
String newsletterPath2 =
savePath
+ File.separator
+ "newsletter"
+ File.separator
+ saveFileName
+ File.separator
+ fileName
+ File.separator
+ "index.html";
File f = new File(newsletterPath);
if (!f.exists())
{
f = new File(newsletterPath2);

}
InputStreamReader read;
StringBuffer sb = new StringBuffer();
try
{
read = new InputStreamReader(new FileInputStream(f), "UTF-8");
BufferedReader reader = new BufferedReader(read);

String line;

while ((line = reader.readLine()) != null)
{

//System.out.print(line);
sb.append(line);

}
}
catch (UnsupportedEncodingException e)
{
// TODO 自动生成 catch 块
e.printStackTrace();
}
catch (FileNotFoundException e)
{
// TODO 自动生成 catch 块
e.printStackTrace();
}
catch (IOException e)
{
// TODO 自动生成 catch 块
e.printStackTrace();
}
//将静态页面中图片路径替换为服务器图片的路径
String oldString = "<img src=\"images/";
String oldString2 = "<IMG SRC=\"images/";

String newString =
"<img src=\"" + urlPath + "/" + "newsletter" + "/" + saveFileName + "/" + fileName + "/" + "images/";

String mailContnet = StringUtil.replaceString(sb.toString(), oldString, newString);
mailContnet = StringUtil.replaceString(mailContnet, oldString2, newString);
newsLetter.setMailContent(mailContnet);
//System.out.println(mailContnet);
//执行发送邮件
super.getService().getNewsletterService().doSendTestEmail(newsLetter);

ActionForward forward = new ActionForward("/system/newsletter.do?method=list");
forward.setRedirect(true);
return forward;
}

你可能感兴趣的:(html,F#)