Comment appeler ma methode dans le main

Fermé
clotidina - 24 juin 2014 à 11:31
irony42 Messages postés 94 Date d'inscription mardi 2 novembre 2010 Statut Membre Dernière intervention 21 octobre 2015 - 25 juin 2014 à 16:40
Bonjour,

j'ai un programme qui recupere le contenu d'une page et le compare et doit envoyer le resultat par mail,
j'ai creer la methode send mail mais je sais pas comment l'appeler dans ma classe main vous pouvez m'aider ?
  static public Map<Integer, ArrayList<Module>> SendMail( Map<Integer,ArrayList<Module>> allResult) {
{

// Recipient's email ID needs to be mentioned.
String to = "***@***";

// Sender's email ID needs to be mentioned
String from = "***@***";

// Assuming you are sending email from localhost

String host = "localdelivery.klee.lan.net";

// Get system properties
Properties properties = System.getProperties();

// Setup mail server
properties.setProperty("mail.smtp.host", host);
System.setProperty("http.proxyPort","3128");
System.setProperty("http.proxyHost","172.20.0.9");

// Get the default Session object.
Session session = Session.getDefaultInstance(properties);

try{
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session);

// Set From: header field of the header.
message.setFrom(new InternetAddress(from));

// Set To: header field of the header.
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));

// Set Subject: header field
message.setSubject("Liste des nouveaux plugins JCMS");
message.setSentDate(new Date());
// Now set the actual message
for (Module module : result) {

message.setText("Le titre du module est: " + module.getTitre() + " sa version est: " + module.getVersion() + " sa liste de comptabilités est:" + module.getCompatibilite() );

}

// Send message
Transport.send(message);
System.out.println("Sent message successfully....");
}catch (MessagingException mex) {
mex.printStackTrace();

}
}
return allResult;

}
voila ma classe main

import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;


public class Main {

public static void main(String[] args) {

ArrayList<Module> newPlugins = Operations.lire();

// Si aucune sérialisation précédente, on sérialise et on sort.
ArrayList<Module> oldPlugins = Operations.deserialiser();

if(null == oldPlugins){
System.out.println("Il n'y a pas d'ancien plugin");
Operations.serialiser(newPlugins);
}else{
Map<Integer,ArrayList<Module>> result = Operations.compare(oldPlugins, newPlugins); // on compare

if (null != result) {
Operations.serialiser(newPlugins);

// On affiche les changements
System.out.println("Les changements sont: ");
System.out.println("the added plugins are : ");
for (Module module : result.get(1)) {

System.out.println("Le titre du module est: " + module.getTitre() + " sa version est: " + module.getVersion() + " sa liste de comptabilités est: ");
System.out.print("<<");
for (String string : module.getCompatibilite())
System.out.print(string + ",");
System.out.println(">>");


}
System.out.println("the updated plugins are : ");
for (Module module : result.get(2)) {

System.out.println("Le titre du module est: " + module.getTitre() + " sa version est: " + module.getVersion() + " sa liste de comptabilités est: ");
System.out.print("<<");
for (String string : module.getCompatibilite())
System.out.print(string + ",");
System.out.println(">>");
Map<Integer, ArrayList<Module>> sent = new TreeMap<Integer,ArrayList<Module>>();
sent= Operations.SendMail(result);


}
} else {
System.out.println("Pas de changements");

Map<Integer, ArrayList<Module>> sent = new TreeMap<Integer,ArrayList<Module>>();
sent= Operations.SendMail(result);
}

}
}




}

1 réponse

irony42 Messages postés 94 Date d'inscription mardi 2 novembre 2010 Statut Membre Dernière intervention 21 octobre 2015 60
25 juin 2014 à 16:40
Le fait de faire ça marche ?

Map<Integer, ArrayList<Module>> mailSended;
mailSended = SendMail(ceQueTuVeuxEnvoyer);

Sinon as-tu les bon imports ?
0