import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
public class ReadHTML {
/**
* @param args
*/
//public static void main(String[] args) {
// TODO Auto-generated method stub
public static String reMailString(){
//String info="";
StringBuffer buff=new StringBuffer();
InputStreamReader in=null;
BufferedReader br=null;
String realPath = Thread.currentThread().getContextClassLoader().getResource("/").getPath();
String path=realPath.replace("classes/", "template/front/emailcode.html");
File file=new File(path);
try {
in=new InputStreamReader(new FileInputStream(file));
br=new BufferedReader(in);
String line=null;
while((line=br.readLine()) != null){
// System.out.println(line);
buff.append(line).append("\n");
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
if(in!=null){
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(br!=null){
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return buff.toString();
}
public static void main(String[] args) {
ReadHTML.reMailString();
}
}
用上面的类进行读取发送到邮箱的HTML代码,再通过java的mail进行邮箱的发送。
如何通过java mail发送很长的HTML代码
最新推荐文章于 2023-05-26 11:40:59 发布