diff --git a/org.adempiere.base/src/org/compiere/util/EMail.java b/org.adempiere.base/src/org/compiere/util/EMail.java index 0acd0d8c43..4d8a9c7f4c 100644 --- a/org.adempiere.base/src/org/compiere/util/EMail.java +++ b/org.adempiere.base/src/org/compiere/util/EMail.java @@ -72,7 +72,7 @@ public final class EMail implements Serializable /** * */ - private static final long serialVersionUID = -2489441683920482601L; + private static final long serialVersionUID = 5355436165040508855L; //use in server bean public final static String HTML_MAIL_MARKER = "ContentType=text/html;"; @@ -602,7 +602,7 @@ public final class EMail implements Serializable } try { - m_from = new InternetAddress (newFrom, true); + m_from = createInternetAddress(newFrom); if (MSysConfig.getBooleanValue(MSysConfig.MAIL_SEND_BCC_TO_FROM, false, Env.getAD_Client_ID(Env.getCtx()))) addBcc(newFrom); } @@ -628,7 +628,7 @@ public final class EMail implements Serializable InternetAddress ia = null; try { - ia = new InternetAddress (newTo, true); + ia = createInternetAddress(newTo); } catch (Exception e) { @@ -679,7 +679,7 @@ public final class EMail implements Serializable InternetAddress ia = null; try { - ia = new InternetAddress (newCc, true); + ia = createInternetAddress(newCc); } catch (Exception e) { @@ -719,7 +719,7 @@ public final class EMail implements Serializable InternetAddress ia = null; try { - ia = new InternetAddress (bccAddress, true); + ia = createInternetAddress(bccAddress); } catch (Exception e) { @@ -758,7 +758,7 @@ public final class EMail implements Serializable InternetAddress ia = null; try { - ia = new InternetAddress (newTo, true); + ia = createInternetAddress(newTo); } catch (Exception e) { @@ -1221,4 +1221,21 @@ public final class EMail implements Serializable additionalHeaders.add(new ValueNamePair(value, name)); } + /** + * Create an internet address with personal if the email address is formatted as "Personal " + * @param email + * @return internet address with personal if defined + * @throws Exception + */ + public static InternetAddress createInternetAddress(String email) throws Exception { + InternetAddress ia = new InternetAddress (email, true); + if (email.contains("<") && email.contains(">")) { + int idx = email.lastIndexOf("<"); + String personal = email.substring(0, idx).trim(); + if (! personal.isEmpty()) + ia.setPersonal(personal); + } + return ia; + } + } // EMail diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java index be27e656c5..54b4ea28d5 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java @@ -524,7 +524,7 @@ public class WEMailDialog extends Window implements EventListener, ValueC return; } - StringTokenizer st = new StringTokenizer(getTo(), " ,;", false); + StringTokenizer st = new StringTokenizer(getTo(), ",;", false); String to = st.nextToken(); EMail email = m_client.createEMail(getFrom(), to, getSubject(), replaceBASE64Img(getMessage()), true); String status = "Check Setup"; @@ -533,7 +533,7 @@ public class WEMailDialog extends Window implements EventListener, ValueC while (st.hasMoreTokens()) email.addTo(st.nextToken()); // cc - StringTokenizer stcc = new StringTokenizer(getCc(), " ,;", false); + StringTokenizer stcc = new StringTokenizer(getCc(), ",;", false); while (stcc.hasMoreTokens()) { String cc = stcc.nextToken();