我工作的一个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(); } }
}
相关分类