Tuesday, May 1, 2018

How to send a batch with emails in android?

Leave a Comment

I want to send several emails to different recipients, but the text of the letters may differ. And I also want to authorize the user and send mail on his behalf, by Intent and the built-in mail client app. And is there any way to do this with one button click, rather than calling up a new email window (activity) for each of these letters and forcing the user to confirms the sending of each letter?

And is there any way to not call the new e-mail window for each of these letters, so that the user confirms the sending of each letter, and do this at the touch of a button?

Maybe are there any third-party libraries or free mail services for this purpose?

1 Answers

Answers 1

You can use simple-java-mail to achieve that.

public static void SendMail(String recipientName,String recipientAddress,String subject,String message,File file,String myAdress,String password) throws IOException{               System.out.println("File size "+file.length());   Email email = new Email();  email.setFromAddress(myAdress.split("@")[0], myAdress);  email.addRecipient(recipientName, recipientAddress, Message.RecipientType.TO);  email.setSubject(subject);  email.setText(message);  if(file!=null)  email.addAttachment(file.getName(),  FileUtils.readFileToByteArray(file),"application/pdf");   String host = myAdress.split("@")[1];   new Mailer(     new ServerConfig("smtp."+host, 587, myAdress, password),     TransportStrategy.SMTP_TLS,     new ProxyConfig("socksproxy."+host, 1080, "proxy user", "proxy password")  ).sendMail(email);   } 

If your client is using Gmail, they have to allow third parties to send mail in their settings

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment