我工作的一个web_application唱Java,servlets,JSP以及使用Apache Tomcat作为应用服务器我做了什么我创建了一个UI用户选择邮件ID的地方(他们可以选择多个)当用户点击发送按钮时,我正在触发我的java类并发送邮件现在我要做什么现在我必须动态地执行此操作,每晚12点钟我必须向某些特定用户发送邮件我必须向其发送邮件的用户我从登录查询中获取该邮件ID,这不是问题我只是想知道如何在午夜时分12:00发送邮件Codding我到现在为止做过servlet类public class EmailSendingServlet extends HttpServlet {private static final long serialVersionUID = 1L;private String host;private
String port;private String user;private String pass;public void init() {
ServletContext context = getServletContext();
host = context.getInitParameter("host");
port = context.getInitParameter("port");
user = context.getInitParameter("user");
pass = context.getInitParameter("pass");}protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String recipient = request.getParameter("To"); // this i will get from login query
String subject = request.getParameter("subject");//this i can define manually
String content = request.getParameter("content");//same for this also
String resultMessage = "";
try {
EmailUtility.sendEmail(host, port, user, pass, recipient, subject,
content);
resultMessage = "The e-mail was sent successfully";
} catch (Exception ex) {
ex.printStackTrace();
resultMessage = "There were an error: " + ex.getMessage();
} }}
添加回答
举报
0/150
提交
取消