English 中文(简体)
java - 如何在某个时候发出电子邮件? [复制]
原标题:java - How to send e-mail at a certain time? [duplicate]

I m 开发一个Java App(JSF 2.0),使用Tamcat 7.0。 我需要每天发送电子邮件。 我会使用 Java邮发送电子邮件,但我如何在一定时间每天发送电子邮件。 中午?

any!

最佳回答
问题回答

最佳和灵活的解决办法是使用Quartz列表器。 你们都需要创造一份工作岗位,并根据你的具体要求启动工作。

For details refer to the official documents

http://quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/"rel=“nofollow> 图瓦卢

you can schedule you email your Quartz scheduler as Umesh suggested, you can use the below code to start off:

//set quartz properties in propreties file or map

SchedulerFactory schedFact = new StdSchedulerFactory();

Scheduler sched = schedFact.getScheduler();

//set these parameters
JobDetail jobDetail = new JobDetail( "Email Job" , Scheduler.DEFAULT_GROUP , MyEmailAction.class );

//add data or objects you may require in your scheduled job
JobDataMap dataMap = jobDetail.getJobDataMap();

dataMap.put("mydata", myDataObj);

SimpleTrigger st = new SimpleTrigger();

st.setName("DeployTrigger");            

//set the time when you want to send email

st.setStartTime( java.util.Date );

sched.scheduleJob( jobDetail , st  );

sched.start();




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...