0
I’m trying to make a program that picks up a list of partners that contain the name, email, and renewal day(like paying monthly fee), and when the day comes, send an email to it.
But I’m having trouble getting the name and email of that particular partner who is on the day of sending the email. I tried to use socio[i]
(which is the name of the list), which is the number you entered in the for
.
In my if
, I’m not being able to compare day_of_month
with the date, date is integer
and it seems to me day_of_month
is of another kind.
Follow my code to see if it helps understand my problem
package trabalho2;
import java.util.ArrayList;
import java.util.Calendar;
import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;
public class Main {
public static void main(String[] args) {
ArrayList <Socios> socios = new ArrayList();
//cadastrando os sócios
Socios socios1 = new Socios("Mateus", "[email protected]", 11);
Socios socios2 = new Socios("Eduardo Moya Simões", "[email protected]", 11);
//isso aqui é tipo colocando o q foi cadastrado na lista
socios.add(socios1);
socios.add(socios2);
Calendar c = Calendar.getInstance();
SimpleEmail email = new SimpleEmail();
email.setSSLOnConnect(true);
email.setHostName("smtp.googlemail.com");
email.setSslSmtpPort("465");
email.setAuthenticator( new DefaultAuthenticator( "[email protected]" , "nossasenha"));
for (int i = 0; i < socios.size(); i++) {
//isso só serve para vc ver como ta funcionando, depois tem q apagar
System.out.println("Socio: " + socios.get(i));
System.out.println(Calendar.DAY_OF_MONTH);
if (c.get(Calendar.DAY_OF_MONTH) = socios(i).getData) {
// função manda e-mail
try {
email.setFrom( "[email protected]", "Socio torcedor");
email.setDebug(true);
email.setSubject( "Pagamento fatura");
email.setMsg("Salve dpoente\n tu tem q pagar sua mensalidade né jumento");
email.addTo(socios.getEmail, socios.getNome);
email.send();
System.out.println("Email enviado para: " + socios.getEmail +" de " + socios.getNome);
}catch (EmailException e) {
e.printStackTrace();
}
}
}
}
}
Thank you, you helped me a lot but help me on the following:
– jão assacino
@I’ve already tried to help?
– Genos
Thank you, you helped me a lot but help me out with the following: "socios.getEmail The problems are: The socios list does not have such methods." I actually created another class called socios with the email, name, and date variables and added the gets and sets. About 'socios(i)', socios is a list, if you notice in the 'for (int i = 0; i < socios.size(); i++)' the intention is to pass through here all the lists, so 'socios' is the name and 'i' is the count;
– jão assacino
when he enters this 'if' the intention is to get the list with that i; for example, no for passed the socios3 list, no if then when I say: 'if (c.get(Calendar.DAY_OF_MONTH) = socios(i).getData)' I am wanting to test the socios 3
– jão assacino
I was writing, kkkkk
– jão assacino