[Schmitzm-commits] r1851 - trunk/schmitzm-core/src/main/java/de/schmitzm/net/mail

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 1 10:56:06 CET 2012


Author: mojays
Date: 2012-02-01 10:56:05 +0100 (Wed, 01 Feb 2012)
New Revision: 1851

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/net/mail/MailUtil.java
Log:
MailUtil: construction of "mailto" parameter list reorganized (because Outlook does not handle empty parameters correctly)

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/net/mail/MailUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/net/mail/MailUtil.java	2012-01-30 23:43:27 UTC (rev 1850)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/net/mail/MailUtil.java	2012-02-01 09:56:05 UTC (rev 1851)
@@ -177,17 +177,36 @@
 				mailBody = mailBody.substring(0, MAX_DESKTOP_MAIL_BODY_SIZE)
 						+ "...\n[...]";
 
-			StringBuffer uriMailStr = new StringBuffer();
-			uriMailStr.append(mailDestAddr != null ? mailDestAddr : "");
-			uriMailStr.append("?SUBJECT=").append(
-					mailSubject != null ? mailSubject : "");
-			if ( mailCcAddr != null && !mailCcAddr.trim().isEmpty() )
-              uriMailStr.append("&CC=").append(mailCcAddr);
-            if ( mailBccAddr != null && !mailBccAddr.trim().isEmpty() )
-              uriMailStr.append("&BCC=").append(mailBccAddr);
-			uriMailStr.append("&BODY=")
-					.append(mailBody != null ? mailBody : "");
-			URI uriMailTo = new URI("mailto", uriMailStr.toString(), null);
+
+//Outlook macht Probleme, wenn der SUBJECT-Parameter leer ist; deshalb Parameter
+//nur setzen, wenn Wert nicht leer!
+//			StringBuffer uriMailStr = new StringBuffer();
+//			uriMailStr.append(mailDestAddr != null ? mailDestAddr : "");
+//			uriMailStr.append("?SUBJECT=").append(
+//					mailSubject != null ? mailSubject : "");
+//			if ( mailCcAddr != null && !mailCcAddr.trim().isEmpty() )
+//              uriMailStr.append("&CC=").append(mailCcAddr);
+//            if ( mailBccAddr != null && !mailBccAddr.trim().isEmpty() )
+//              uriMailStr.append("&BCC=").append(mailBccAddr);
+//			uriMailStr.append("&BODY=")
+//					.append(mailBody != null ? mailBody : "");
+			String uriMailStr = "";
+			if ( !StringUtils.isBlank(mailSubject) )
+			  uriMailStr += "&SUBJECT=" + mailSubject;
+			if ( !StringUtils.isBlank(mailCcAddr) )
+			  uriMailStr += "&CC=" + mailCcAddr;
+            if ( !StringUtils.isBlank(mailBccAddr) )
+              uriMailStr += "&BCC=" + mailBccAddr;
+            if ( !StringUtils.isBlank(mailBody) )
+              uriMailStr += "&BODY=" + mailBody;
+			// replace leading & with ?
+            if ( uriMailStr.startsWith("&") )
+              uriMailStr = "?" + uriMailStr.substring(1);
+			// add TO addresses at the beginning
+            if ( !StringUtils.isBlank(mailDestAddr) )
+              uriMailStr = mailDestAddr + uriMailStr;
+			
+			URI uriMailTo = new URI("mailto", uriMailStr, null);
 			Desktop.getDesktop().mail(uriMailTo);
 		} catch (Exception err) {
 			ExceptionDialog.show(null, err, null,



More information about the Schmitzm-commits mailing list