mirror of https://github.com/M66B/FairEmail.git
Guess first/lastname
This commit is contained in:
parent
526f208131
commit
984ef5f4c6
|
@ -57,13 +57,28 @@ public class EntityAnswer implements Serializable {
|
||||||
|
|
||||||
String name = null;
|
String name = null;
|
||||||
String email = null;
|
String email = null;
|
||||||
|
String first = null;
|
||||||
|
String last = null;
|
||||||
if (from != null && from.length > 0) {
|
if (from != null && from.length > 0) {
|
||||||
name = ((InternetAddress) from[0]).getPersonal();
|
name = ((InternetAddress) from[0]).getPersonal();
|
||||||
email = ((InternetAddress) from[0]).getAddress();
|
email = ((InternetAddress) from[0]).getAddress();
|
||||||
}
|
}
|
||||||
|
if (name != null) {
|
||||||
|
name = name.trim();
|
||||||
|
int c = name.lastIndexOf(",");
|
||||||
|
if (c < 0) {
|
||||||
|
first = name;
|
||||||
|
last = name;
|
||||||
|
} else {
|
||||||
|
first = name.substring(c + 1).trim();
|
||||||
|
last = name.substring(0, c).trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String text = answer.text;
|
String text = answer.text;
|
||||||
text = text.replace("$name$", name == null ? "" : name);
|
text = text.replace("$name$", name == null ? "" : name);
|
||||||
|
text = text.replace("$firstname$", first == null ? "" : first);
|
||||||
|
text = text.replace("$lastname$", last == null ? "" : last);
|
||||||
text = text.replace("$email$", email == null ? "" : email);
|
text = text.replace("$email$", email == null ? "" : email);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|
Loading…
Reference in New Issue