Bonsoir,
Je developpe une application workflow en java netbeans,et la je dois programmer des notifications qui seront envoyées a des boites gmail,j"ai inserer ce code mais il ne marche pas. s'il vous plait est ce que quelqu'un peut me donner une solution a mon probleme
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 application; import java.util.Properties; import javax.mail.Message; import javax.mail.Session; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import java.io.*; import java.util.*; import javax.mail.*; import javax.mail.internet.*; /** * * @author EliteBook */ public class mail { private String username="sousssu.h@gmail.com"; private String password="424365562"; public void envoyer(){ Properties props= new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "587"); Session session= Session.getInstance(props,new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication(){ return new PasswordAuthentication (username,password); } }); try{ Message message=new MimeMessage(session); message.setFrom(new InternetAddress("sousssu.h@gmail.com")); message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("JULI.k@gmail.com")); message.setSubject("test"); message.setText("bonjour"); Transport.send(message); System.out.println("message envoyé"); } catch(MessagingException e){ throw new RuntimeException(); } } /** Programme principal*/ public static void main(String[] av) { mail evet=new mail(); evet.envoyer(); } }
c'est ce qui m'affiche apres execution:
Exception in thread "main" java.lang.RuntimeException
at application.mail.envoyer(mail.java:48)Java Result: 1
at application.mail.main(mail.java:56)
Partager