Hi I’m implementing Email template in Android, iOS was find no problem but I received this error and don’t understand how to handle the ‘criteria’ object.
The ‘addresses’ are OK checked but no idea what to do with criteria.
Thanks, Mario
Hi I’m implementing Email template in Android, iOS was find no problem but I received this error and don’t understand how to handle the ‘criteria’ object.
The ‘addresses’ are OK checked but no idea what to do with criteria.
Thanks, Mario
Hi Mario,
Could you please show your Java (or Kotlin) code that composes an email to send from a template?
Regards,
Mark
private void sendEmail() {
Log.i(“ResuPendiAutorizacion”, “sendEmail”);
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
String email = settings.getString(“identity”, null);
Set addresses = new HashSet<>();
addresses.add(email);
addresses.add(“mario@TargettAcceso.com”);
Log.i("ResuPendiAutorizacion", "addresses: " + addresses);
Map<String, String> templateValues = new HashMap<>();
templateValues.put("nombre", name);
templateValues.put("apellido", lastName);
templateValues.put("destino", destinoData);
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.US);
String strDesdeDate = dateFormat.format(desdeDate);
templateValues.put("desde", strDesdeDate);
templateValues.put("hasta", "");
if (noAutorizado) {
templateValues.put("noAutorizado", "NO AUTORIZADO");
} else {
templateValues.put("noAutorizado", "AUTORIZADO");
}
EmailEnvelope envelope = new EmailEnvelope();
envelope.setTo(addresses);
Backendless.Messaging.sendEmailFromTemplate("Autorization Result", envelope, templateValues, new AsyncCallback<MessageStatus>() {
@Override
public void handleResponse(MessageStatus response) {
Log.i("ResuPendiAutorizacion", "Email has been sent");
}
@Override
public void handleFault(BackendlessFault fault) {
Log.e("ResuPendiAutorizacion", fault.getMessage());
}
});
}
Sorry I don’t know how to paste all the code in the “code page”
Thanks, Mario
PD. Also check Example: Target Individual Devices - Backendless SDK for Android/Java API Documentation
change addPushSinglecast to deliveryOptions.setPushSinglecast();
Hi @Mario_Ghersi!
I’ve created an internal ticket BKNDLSS-30190 to investigate this issue.
We will let you know as soon as the issue is fixed.
Regards,
Alexander
@Mario_Ghersi,
could you make such changes in your code and check if everything works?
EmailEnvelope envelope = new EmailEnvelope();
envelope.setTo(addresses);
→
EmailEnvelope envelope = new EmailEnvelope();
envelope.addTo(addresses);
Regards,
Alexander
Still the same problem:
E/ResuPendiAutorizacion: Either ‘criteria’ or list of ‘addresses’ should be set and should not be empty.
And what about the “criteria” ?
Thanks, Mario
Hi Mario,
Could you please check what version of the Backendless SDK for Android you’re using?
Regards,
Mark
implementation group: ‘com.backendless’, name: ‘backendless’, version: ‘5.3.0’
Hi, @Mario_Ghersi
Could you try changing the Backendless SDK version to the latest, which is 6.3.5. And try sending the email again, please. With this part of code:
EmailEnvelope envelope = new EmailEnvelope();
envelope.addTo(addresses);
Will be looking forward to your result.
Regards,
Marina
Hi, @Mario_Ghersi
We have prepared a fix for setting (setTo) the new addresses (BKNDLSS-30190), which will be released in the next SDK version, but from your last post, if you tried to change the code and update the Backendless version, it is clear that this is not your issue. Unfortunately, we have not been able to reproduce the described problem on our side.
Please check again that there are emails in the addresses. Let’s try to check our simple code in your application, when you send the code, does it work for you? (Don’t forget to change the template name and email).
final Set<String> addresses = new HashSet<>();
String email = "user1@user.com";
addresses.add(email);
addresses.add("user2@user.com");
Map<String, String> templateValues = new HashMap<>();
templateValues.put("secondName", "User_name");
templateValues.put("age", "25");
EmailEnvelope envelope = new EmailEnvelope();
envelope.addTo(addresses);
Backendless.Messaging.sendEmailFromTemplate("Template_Name", envelope,templateValues, new AsyncCallback<MessageStatus>() {
@Override
public void handleResponse(MessageStatus response) {
System.out.print("Email has been sent to " + addresses);
}
@Override
public void handleFault(BackendlessFault fault) {
System.out.print(fault.getMessage());
}
});
And if the problem still exists, please provide us with a simple reproducible example code (project) so that we can check it from our side.
Regards,
Marina