diff -urN libreoffice-4.0.3.3.26.old/shell/source/cmdmail/cmdmailsuppl.cxx libreoffice-4.0.3.3.26/shell/source/cmdmail/cmdmailsuppl.cxx
--- libreoffice-4.0.3.3.26.old/shell/source/cmdmail/cmdmailsuppl.cxx	2014-10-29 10:24:14.796338879 +0100
+++ libreoffice-4.0.3.3.26/shell/source/cmdmail/cmdmailsuppl.cxx	2014-10-29 11:06:51.333338574 +0100
@@ -109,6 +109,47 @@
 // XSimpleMailClient
 //------------------------------------------------
 
+namespace {
+
+void appendShellWord(OStringBuffer & buffer, OUString const & word, bool strict)
+{
+    OString sys;
+    if (!word.convertToString(
+            &sys, osl_getThreadTextEncoding(),
+            (strict
+             ? (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
+                | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)
+             : OUSTRING_TO_OSTRING_CVTFLAGS)))
+    {
+        throw css::uno::Exception(
+            ("Could not convert \"" + word + "\" to encoding #"
+             + OUString::valueOf(osl_getThreadTextEncoding())),
+            css::uno::Reference<css::uno::XInterface>());
+    }
+    buffer.append('\'');
+    for (sal_Int32 i = 0; i != sys.getLength(); ++i) {
+        char c = sys[i];
+        switch (c) {
+        case 0:
+            if (strict) {
+                throw css::uno::Exception(
+                    "Could not convert word containing NUL, \"" + word + "\"",
+                    css::uno::Reference<css::uno::XInterface>());
+            }
+            break;
+        case '\'':
+            buffer.append("'\\''");
+            break;
+        default:
+            buffer.append(c);
+            break;
+        }
+    }
+    buffer.append('\'');
+}
+
+}
+
 void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailMessage >& xSimpleMailMessage, sal_Int32 /*aFlag*/ )
     throw (IllegalArgumentException, Exception, RuntimeException)
 {
@@ -126,9 +167,6 @@
             static_cast < XSimpleMailClient * > (this) );
     }
 
-    OStringBuffer aBuffer;
-    aBuffer.append("\"");
-
     OUString aProgramURL(RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/program/senddoc"));
     rtl::Bootstrap::expandMacros(aProgramURL);
 
@@ -140,8 +178,8 @@
             static_cast < XSimpleMailClient * > (this));
     }
 
-    aBuffer.append(OUStringToOString(aProgram, osl_getThreadTextEncoding()));
-    aBuffer.append("\" ");
+    OStringBuffer aBuffer;
+    appendShellWord(aBuffer, aProgram, true);
 
     try
     {
@@ -178,13 +216,12 @@
                 // make sure we have a system path
                 FileBase::getSystemPathFromFileURL( aMailer, aMailer );
 
-                aBuffer.append("--mailclient ");
-                aBuffer.append(OUStringToOString( aMailer, osl_getThreadTextEncoding() ));
-                aBuffer.append(" ");
+                aBuffer.append(" --mailclient ");
+                appendShellWord(aBuffer, aMailer, true);
             }
 #ifdef MACOSX
             else
-                aBuffer.append("--mailclient Mail ");
+                aBuffer.append(" --mailclient Mail");
 #endif
         }
 
@@ -198,20 +235,23 @@
         throw;
     }
 
+    // Convert from, to, etc. in a best-effort rather than a strict way to the
+    // system encoding, based on the assumption that the relevant address parts
+    // of those strings are ASCII anyway and any problematic characters are only
+    // in the human-readable, informational-only parts:
+
     // Append originator if set in the message
     if ( !xSimpleMailMessage->getOriginator().isEmpty() )
     {
-        aBuffer.append("--from \"");
-        aBuffer.append(OUStringToOString(xSimpleMailMessage->getOriginator(), osl_getThreadTextEncoding()));
-        aBuffer.append("\" ");
+        aBuffer.append(" --from ");
+        appendShellWord(aBuffer, xSimpleMailMessage->getOriginator(), false);
     }
 
     // Append receipient if set in the message
     if ( !xSimpleMailMessage->getRecipient().isEmpty() )
     {
-        aBuffer.append("--to \"");
-        aBuffer.append(OUStringToOString(xSimpleMailMessage->getRecipient(), osl_getThreadTextEncoding()));
-        aBuffer.append("\" ");
+        aBuffer.append(" --to ");
+        appendShellWord(aBuffer, xSimpleMailMessage->getRecipient(), false);
     }
 
     // Append carbon copy receipients set in the message
@@ -219,9 +259,8 @@
     sal_Int32 n, nmax = aStringList.getLength();
     for ( n = 0; n < nmax; n++ )
     {
-        aBuffer.append("--cc \"");
-        aBuffer.append(OUStringToOString(aStringList[n], osl_getThreadTextEncoding()));
-        aBuffer.append("\" ");
+        aBuffer.append(" --cc ");
+        appendShellWord(aBuffer, aStringList[n], false);
     }
 
     // Append blind carbon copy receipients set in the message
@@ -229,17 +268,15 @@
     nmax = aStringList.getLength();
     for ( n = 0; n < nmax; n++ )
     {
-        aBuffer.append("--bcc \"");
-        aBuffer.append(OUStringToOString(aStringList[n], osl_getThreadTextEncoding()));
-        aBuffer.append("\" ");
+        aBuffer.append(" --bcc ");
+        appendShellWord(aBuffer, aStringList[n], false);
     }
 
     // Append subject if set in the message
     if ( !xSimpleMailMessage->getSubject().isEmpty() )
     {
-        aBuffer.append("--subject \"");
-        aBuffer.append(OUStringToOString(xSimpleMailMessage->getSubject(), osl_getThreadTextEncoding()));
-        aBuffer.append("\" ");
+        aBuffer.append(" --subject ");
+        appendShellWord(aBuffer, xSimpleMailMessage->getSubject(), false);
     }
 
     // Append attachments set in the message
@@ -250,9 +287,8 @@
         OUString aSystemPath;
         if ( FileBase::E_None == FileBase::getSystemPathFromFileURL(aStringList[n], aSystemPath) )
         {
-            aBuffer.append("--attach \"");
-            aBuffer.append(OUStringToOString(aSystemPath, osl_getThreadTextEncoding()));
-            aBuffer.append("\" ");
+            aBuffer.append(" --attach ");
+            appendShellWord(aBuffer, aSystemPath, true);
         }
     }
 
