Skip to content

Instantly share code, notes, and snippets.

@RohanNavlakhe2
Created January 2, 2022 14:08
Show Gist options
  • Save RohanNavlakhe2/d37809fcf211741393187ccb437f7462 to your computer and use it in GitHub Desktop.
Save RohanNavlakhe2/d37809fcf211741393187ccb437f7462 to your computer and use it in GitHub Desktop.
String[] emailContent = {"Hii Abhi!","Here is my new article","abhi@gmail.com"};
Observable.just(emailContent)
.map(emailData -> {
GMailSender sender = new GMailSender("senderemailid@gmail.com",
"password");
sender.sendMail(emailData[0], emailData[1],
"senderemailid",emailData[2]);
return "Email Successfully sent";
})
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(new DisposableObserver<String>() {
@Override
public void onNext(String s) {
//s wil contain what map() will return
Toast.makeText(context, s , Toast.LENGTH_SHORT).show();
}
@Override
public void onError(Throwable e) {
Toast.makeText(context,"Email Send failed", Toast.LENGTH_SHORT).show();
}
@Override
public void onComplete() {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment