Bonjour svp j'essaye d'envoyer un mail avec Quartz .
mais ca marche pas je trouve pas le problème quelqu'un puisse m'aider
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 
package test.locataire.bean;
 
import java.util.logging.Level;
import java.util.logging.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.util.Date;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.SimpleTrigger;
import org.quartz.impl.StdSchedulerFactory;
import javax.mail.MessagingException;
import javax.mail.internet.AddressException;
 
import org.quartz.jobs.ee.mail.SendMailJob;
public class sendMailJob{
        public  sendMailJob()  {
        try {
            SchedulerFactory sf = new StdSchedulerFactory();
            Scheduler sched = null;
            try {
                sched = sf.getScheduler();
            } catch (SchedulerException ex) {
                ex.printStackTrace();
            }
            sched.start();
            JobDetail jobDetail = new JobDetail("myJob", Scheduler.DEFAULT_GROUP, SendMailJob.class);
            JobDataMap map = new JobDataMap();
            map.put(SendMailJob.PROP_SMTP_HOST, "smtp.gmail.com");
            map.put(SendMailJob.PROP_SENDER, "test@gmail.com");
            map.put(SendMailJob.PROP_RECIPIENT, "test@gmail.com");
            map.put(SendMailJob.PROP_SUBJECT, "hello");
            map.put(SendMailJob.PROP_MESSAGE, "salut...");
            jobDetail.setJobDataMap(map);
            SimpleTrigger st = new SimpleTrigger("mytrigger", sched.DEFAULT_GROUP, new Date(), null, SimpleTrigger.REPEAT_INDEFINITELY, 240L * 1000L);
            sched.scheduleJob(jobDetail, st);
        } catch (SchedulerException ex) {
            ex.printStackTrace();
        }
}
public static void main(String args[]){
    try{
            sendMailJob sendMailJob = new sendMailJob();
    }catch(Exception e){System.out.println("***************************");}
  }
 
 
}