1f8e2c85aSAndrew Rist /**************************************************************
2ae77b8caSAriel Constenla-Haile  *
3f8e2c85aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e2c85aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e2c85aSAndrew Rist  * distributed with this work for additional information
6f8e2c85aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e2c85aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e2c85aSAndrew Rist  * "License"); you may not use this file except in compliance
9f8e2c85aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10ae77b8caSAriel Constenla-Haile  *
11f8e2c85aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12ae77b8caSAriel Constenla-Haile  *
13f8e2c85aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e2c85aSAndrew Rist  * software distributed under the License is distributed on an
15f8e2c85aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e2c85aSAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e2c85aSAndrew Rist  * specific language governing permissions and limitations
18f8e2c85aSAndrew Rist  * under the License.
19ae77b8caSAriel Constenla-Haile  *
20f8e2c85aSAndrew Rist  *************************************************************/
21f8e2c85aSAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_shell.hxx"
24ae77b8caSAriel Constenla-Haile 
25ae77b8caSAriel Constenla-Haile #include "sysmailclient.hxx"
26ae77b8caSAriel Constenla-Haile #include "sysmailmsg.hxx"
27ae77b8caSAriel Constenla-Haile 
28ae77b8caSAriel Constenla-Haile #include <com/sun/star/system/MailClientFlags.hpp>
29ae77b8caSAriel Constenla-Haile #include <com/sun/star/system/XMailMessage.hpp>
30ae77b8caSAriel Constenla-Haile 
31cdf0e10cSrcweir #include <osl/diagnose.h>
32cdf0e10cSrcweir #include <osl/process.h>
33cdf0e10cSrcweir #include <rtl/bootstrap.hxx>
34cdf0e10cSrcweir #include <osl/file.hxx>
35ae77b8caSAriel Constenla-Haile #include <rtl/ustrbuf.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #define WIN32_LEAN_AND_MEAN
38cdf0e10cSrcweir #if defined _MSC_VER
39cdf0e10cSrcweir #pragma warning(push, 1)
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #include <windows.h>
42cdf0e10cSrcweir #include <mapi.h>
43cdf0e10cSrcweir #if defined _MSC_VER
44cdf0e10cSrcweir #pragma warning(pop)
45ae77b8caSAriel Constenla-Haile #endif
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include <process.h>
48cdf0e10cSrcweir #include <vector>
49cdf0e10cSrcweir 
5033bc51b9SAriel Constenla-Haile using css::uno::UNO_QUERY;
51cdf0e10cSrcweir using css::uno::Reference;
52cdf0e10cSrcweir using css::uno::Exception;
53cdf0e10cSrcweir using css::uno::RuntimeException;
54cdf0e10cSrcweir using css::uno::Sequence;
55cdf0e10cSrcweir using css::lang::IllegalArgumentException;
56cdf0e10cSrcweir 
57ae77b8caSAriel Constenla-Haile using css::system::XMailClient;
58ae77b8caSAriel Constenla-Haile using css::system::XMailMessage;
59ae77b8caSAriel Constenla-Haile using css::system::XMailMessage;
60ae77b8caSAriel Constenla-Haile using css::system::MailClientFlags::NO_USER_INTERFACE;
61ae77b8caSAriel Constenla-Haile using css::system::MailClientFlags::NO_LOGON_DIALOG;
62ae77b8caSAriel Constenla-Haile 
63ae77b8caSAriel Constenla-Haile using rtl::OUString;
64ae77b8caSAriel Constenla-Haile using rtl::OUStringBuffer;
65cdf0e10cSrcweir 
66ae77b8caSAriel Constenla-Haile namespace shell
67ae77b8caSAriel Constenla-Haile {
68cdf0e10cSrcweir namespace /* private */
69ae77b8caSAriel Constenla-Haile {
70ae77b8caSAriel Constenla-Haile     typedef std::vector<rtl::OUString> StringList_t;
71ae77b8caSAriel Constenla-Haile     typedef StringList_t::const_iterator StringListIterator_t;
72ae77b8caSAriel Constenla-Haile 
73ae77b8caSAriel Constenla-Haile     const rtl::OUString TO = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--to"));
74ae77b8caSAriel Constenla-Haile     const rtl::OUString CC = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--cc"));
75ae77b8caSAriel Constenla-Haile     const rtl::OUString BCC = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--bcc"));
76ae77b8caSAriel Constenla-Haile     const rtl::OUString FROM = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--from"));
77ae77b8caSAriel Constenla-Haile     const rtl::OUString SUBJECT = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--subject"));
78ae77b8caSAriel Constenla-Haile     const rtl::OUString BODY = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--body"));
79ae77b8caSAriel Constenla-Haile     const rtl::OUString ATTACH = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--attach"));
80ae77b8caSAriel Constenla-Haile     const rtl::OUString FLAG_MAPI_DIALOG = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--mapi-dialog"));
81ae77b8caSAriel Constenla-Haile     const rtl::OUString FLAG_MAPI_LOGON_UI = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--mapi-logon-ui"));
82ae77b8caSAriel Constenla-Haile 
quoteString(const OUString & rStr)83ae77b8caSAriel Constenla-Haile     static OUString quoteString( const OUString& rStr )
84ae77b8caSAriel Constenla-Haile     {
85ae77b8caSAriel Constenla-Haile         rtl::OUStringBuffer quoted;
86ae77b8caSAriel Constenla-Haile         quoted.append(sal_Unicode('"'));
87ae77b8caSAriel Constenla-Haile         quoted.append(rStr);
88ae77b8caSAriel Constenla-Haile         quoted.append(sal_Unicode('"'));
89ae77b8caSAriel Constenla-Haile 
90ae77b8caSAriel Constenla-Haile         return quoted.makeStringAndClear();
91ae77b8caSAriel Constenla-Haile     }
92ae77b8caSAriel Constenla-Haile 
quoteAndEscape(const OUString & rStr)93ae77b8caSAriel Constenla-Haile     static OUString quoteAndEscape( const OUString &rStr )
94ae77b8caSAriel Constenla-Haile     {
95ae77b8caSAriel Constenla-Haile         OUStringBuffer aBuffer;
96ae77b8caSAriel Constenla-Haile         aBuffer.append(sal_Unicode('"'));
97ae77b8caSAriel Constenla-Haile 
98ae77b8caSAriel Constenla-Haile         sal_Int32 nIndex = rStr.indexOf(sal_Unicode('"'));
99ae77b8caSAriel Constenla-Haile         if ( nIndex == -1 )
100ae77b8caSAriel Constenla-Haile             aBuffer.append( rStr );
101ae77b8caSAriel Constenla-Haile         else
102ae77b8caSAriel Constenla-Haile         {
103ae77b8caSAriel Constenla-Haile             const sal_Unicode *pStart = rStr.getStr();
104ae77b8caSAriel Constenla-Haile             const sal_Unicode *pFrom = pStart;
105ae77b8caSAriel Constenla-Haile             const sal_Int32 nLen = rStr.getLength();
106ae77b8caSAriel Constenla-Haile             sal_Int32 nPrev = 0;;
107ae77b8caSAriel Constenla-Haile             do
108ae77b8caSAriel Constenla-Haile             {
109ae77b8caSAriel Constenla-Haile                 aBuffer.append( pFrom, nIndex - nPrev );
110ae77b8caSAriel Constenla-Haile                 aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\\\"" ) );
111ae77b8caSAriel Constenla-Haile                 nIndex++;
112ae77b8caSAriel Constenla-Haile                 pFrom = pStart + nIndex;
113ae77b8caSAriel Constenla-Haile                 nPrev = nIndex;
114ae77b8caSAriel Constenla-Haile             }
115ae77b8caSAriel Constenla-Haile             while ( ( nIndex = rStr.indexOf( '"' , nIndex ) ) != -1  );
116ae77b8caSAriel Constenla-Haile 
117ae77b8caSAriel Constenla-Haile             aBuffer.append( pFrom, nLen - nPrev );
118ae77b8caSAriel Constenla-Haile         }
119ae77b8caSAriel Constenla-Haile 
120ae77b8caSAriel Constenla-Haile         aBuffer.append(sal_Unicode('"'));
121ae77b8caSAriel Constenla-Haile 
122ae77b8caSAriel Constenla-Haile         return aBuffer.makeStringAndClear();
123ae77b8caSAriel Constenla-Haile     }
124ae77b8caSAriel Constenla-Haile 
125ae77b8caSAriel Constenla-Haile     /** @internal
126ae77b8caSAriel Constenla-Haile         look if an alternative program is configured
127cdf0e10cSrcweir         which should be used as senddoc executable */
getAlternativeSenddocUrl()128ae77b8caSAriel Constenla-Haile     static rtl::OUString getAlternativeSenddocUrl()
129cdf0e10cSrcweir     {
130cdf0e10cSrcweir         rtl::OUString altSenddocUrl;
131cdf0e10cSrcweir         HKEY hkey;
132*599cc5b4SOliver-Rainer Wittmann         LONG lret = RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\OpenOffice\\SendAsEMailClient", &hkey);
133cdf0e10cSrcweir         if (lret == ERROR_SUCCESS)
134cdf0e10cSrcweir         {
135cdf0e10cSrcweir             wchar_t buff[MAX_PATH];
136cdf0e10cSrcweir             LONG sz = sizeof(buff);
137ae77b8caSAriel Constenla-Haile             lret = RegQueryValueW(hkey, NULL, buff, &sz);
138cdf0e10cSrcweir             if (lret == ERROR_SUCCESS)
139ae77b8caSAriel Constenla-Haile             {
140cdf0e10cSrcweir                 osl::FileBase::getFileURLFromSystemPath(reinterpret_cast<const sal_Unicode*>(buff), altSenddocUrl);
141ae77b8caSAriel Constenla-Haile             }
142cdf0e10cSrcweir             RegCloseKey(hkey);
143cdf0e10cSrcweir         }
144cdf0e10cSrcweir         return altSenddocUrl;
145cdf0e10cSrcweir     }
146ae77b8caSAriel Constenla-Haile 
147cdf0e10cSrcweir     /**
148cdf0e10cSrcweir         Returns the absolute file Url of the senddoc executable.
149ae77b8caSAriel Constenla-Haile 
150cdf0e10cSrcweir         @returns
151cdf0e10cSrcweir         the absolute file Url of the senddoc executable. In case
152cdf0e10cSrcweir         of an error an empty string will be returned.
153cdf0e10cSrcweir     */
getSenddocUrl()154ae77b8caSAriel Constenla-Haile     static rtl::OUString getSenddocUrl()
155cdf0e10cSrcweir     {
156cdf0e10cSrcweir         rtl::OUString senddocUrl = getAlternativeSenddocUrl();
157ae77b8caSAriel Constenla-Haile 
158cdf0e10cSrcweir         if (senddocUrl.getLength() == 0)
159cdf0e10cSrcweir         {
160cdf0e10cSrcweir             senddocUrl = rtl::OUString(
161cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
162cdf0e10cSrcweir                     "$OOO_BASE_DIR/program/senddoc.exe"));
163cdf0e10cSrcweir             rtl::Bootstrap::expandMacros(senddocUrl); //TODO: detect failure
164ae77b8caSAriel Constenla-Haile         }
165ae77b8caSAriel Constenla-Haile         return senddocUrl;
166cdf0e10cSrcweir     }
167ae77b8caSAriel Constenla-Haile 
168cdf0e10cSrcweir     /**
169cdf0e10cSrcweir         Execute Senddoc.exe which a MAPI wrapper.
170cdf0e10cSrcweir         @param rCommandArgs
171ae77b8caSAriel Constenla-Haile                 [in] the arguments to be passed to Senddoc.exe
172cdf0e10cSrcweir         @returns
173ae77b8caSAriel Constenla-Haile                 <TRUE/> on success.
174cdf0e10cSrcweir     */
executeSenddoc(const StringList_t & rCommandArgs)175ae77b8caSAriel Constenla-Haile     static bool executeSenddoc(const StringList_t& rCommandArgs)
176ae77b8caSAriel Constenla-Haile     {
177cdf0e10cSrcweir         rtl::OUString senddocUrl = getSenddocUrl();
178cdf0e10cSrcweir         if (senddocUrl.getLength() == 0)
179cdf0e10cSrcweir             return false;
180cdf0e10cSrcweir 
181ae77b8caSAriel Constenla-Haile         oslProcess proc;
182cdf0e10cSrcweir         oslProcessError err = osl_Process_E_Unknown;
183ae77b8caSAriel Constenla-Haile 
184ae77b8caSAriel Constenla-Haile         /* for efficiency reasons we are using a 'bad' cast here
185cdf0e10cSrcweir         as a vector or rtl::OUStrings is nothing else than
186cdf0e10cSrcweir         an array of pointers to rtl_uString's */
187cdf0e10cSrcweir         err = osl_executeProcess(
188cdf0e10cSrcweir             senddocUrl.pData,
189ae77b8caSAriel Constenla-Haile             (rtl_uString**)&rCommandArgs[0],
190cdf0e10cSrcweir             rCommandArgs.size(),
191cdf0e10cSrcweir             osl_Process_WAIT | osl_Process_DETACHED,
192cdf0e10cSrcweir             NULL,
193cdf0e10cSrcweir             NULL,
194cdf0e10cSrcweir             NULL,
195cdf0e10cSrcweir             0,
196cdf0e10cSrcweir             &proc);
197ae77b8caSAriel Constenla-Haile 
198cdf0e10cSrcweir         if (err != osl_Process_E_None)
199cdf0e10cSrcweir             return false;
200ae77b8caSAriel Constenla-Haile 
201cdf0e10cSrcweir         oslProcessInfo procInfo;
202ae77b8caSAriel Constenla-Haile         procInfo.Size = sizeof(oslProcessInfo);
203cdf0e10cSrcweir         osl_getProcessInfo(proc, osl_Process_EXITCODE, &procInfo);
204ae77b8caSAriel Constenla-Haile         osl_freeProcessHandle(proc);
205ae77b8caSAriel Constenla-Haile         return (procInfo.Code == SUCCESS_SUCCESS);
206cdf0e10cSrcweir     }
207ae77b8caSAriel Constenla-Haile } // namespace private
208ae77b8caSAriel Constenla-Haile 
209cdf0e10cSrcweir 
createMailMessage()210ae77b8caSAriel Constenla-Haile Reference<XMailMessage> SAL_CALL WinSysMailClient::createMailMessage()
211cdf0e10cSrcweir     throw (RuntimeException)
212cdf0e10cSrcweir {
213ae77b8caSAriel Constenla-Haile     return Reference<XMailMessage>( new WinSysMailMsg() );
214cdf0e10cSrcweir }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir /**
217cdf0e10cSrcweir     Assemble a command line for SendDoc.exe out of the members
218ae77b8caSAriel Constenla-Haile     of the supplied XMailMessage.
219ae77b8caSAriel Constenla-Haile 
220ae77b8caSAriel Constenla-Haile     @param xMailMessage
221cdf0e10cSrcweir     [in] the mail message.
222ae77b8caSAriel Constenla-Haile 
223cdf0e10cSrcweir     @param aFlags
224ae77b8caSAriel Constenla-Haile     [in] different flags to be used with the system mail service.
225ae77b8caSAriel Constenla-Haile 
226cdf0e10cSrcweir     @param rCommandArgs
227cdf0e10cSrcweir     [in|out] a buffer for the command line arguments. The buffer
228ae77b8caSAriel Constenla-Haile     is assumed to be empty.
229ae77b8caSAriel Constenla-Haile 
230cdf0e10cSrcweir     @throws com::sun::star::lang::IllegalArgumentException
231cdf0e10cSrcweir     if an invalid file URL has been detected in the attachment list.
232cdf0e10cSrcweir */
assembleCommandLine(const Reference<XMailMessage> & xMailMessage,sal_Int32 aFlag,StringList_t & rCommandArgs)233ae77b8caSAriel Constenla-Haile void WinSysMailClient::assembleCommandLine(
234ae77b8caSAriel Constenla-Haile     const Reference<XMailMessage>& xMailMessage,
235ae77b8caSAriel Constenla-Haile     sal_Int32 aFlag,
236ae77b8caSAriel Constenla-Haile     StringList_t& rCommandArgs)
237cdf0e10cSrcweir {
238cdf0e10cSrcweir     OSL_ENSURE(rCommandArgs.size() == 0, "Provided command argument buffer not empty");
23933bc51b9SAriel Constenla-Haile 
240ae77b8caSAriel Constenla-Haile     rtl::OUString to = xMailMessage->getRecipient();
241cdf0e10cSrcweir     if (to.getLength() > 0)
242cdf0e10cSrcweir     {
243cdf0e10cSrcweir         rCommandArgs.push_back(TO);
244cdf0e10cSrcweir         rCommandArgs.push_back(to);
245cdf0e10cSrcweir     }
246ae77b8caSAriel Constenla-Haile 
247ae77b8caSAriel Constenla-Haile     Sequence<rtl::OUString> ccRecipients = xMailMessage->getCcRecipient();
248cdf0e10cSrcweir     for (int i = 0; i < ccRecipients.getLength(); i++)
249cdf0e10cSrcweir     {
250cdf0e10cSrcweir         rCommandArgs.push_back(CC);
251cdf0e10cSrcweir         rCommandArgs.push_back(ccRecipients[i]);
252cdf0e10cSrcweir     }
253ae77b8caSAriel Constenla-Haile 
254ae77b8caSAriel Constenla-Haile     Sequence<rtl::OUString> bccRecipients = xMailMessage->getBccRecipient();
255cdf0e10cSrcweir     for (int i = 0; i < bccRecipients.getLength(); i++)
256cdf0e10cSrcweir     {
257cdf0e10cSrcweir         rCommandArgs.push_back(BCC);
258cdf0e10cSrcweir         rCommandArgs.push_back(bccRecipients[i]);
259cdf0e10cSrcweir     }
260ae77b8caSAriel Constenla-Haile 
261ae77b8caSAriel Constenla-Haile     rtl::OUString from = xMailMessage->getOriginator();
262cdf0e10cSrcweir     if (from.getLength() > 0)
263cdf0e10cSrcweir     {
264cdf0e10cSrcweir         rCommandArgs.push_back(FROM);
265cdf0e10cSrcweir         rCommandArgs.push_back(from);
266cdf0e10cSrcweir     }
267ae77b8caSAriel Constenla-Haile 
268ae77b8caSAriel Constenla-Haile     Sequence<rtl::OUString> attachments = xMailMessage->getAttachement();
269cdf0e10cSrcweir     for (int i = 0; i < attachments.getLength(); i++)
270cdf0e10cSrcweir     {
271cdf0e10cSrcweir         rtl::OUString sysPath;
272cdf0e10cSrcweir         osl::FileBase::RC err = osl::FileBase::getSystemPathFromFileURL(attachments[i], sysPath);
273cdf0e10cSrcweir         if (err != osl::FileBase::E_None)
274cdf0e10cSrcweir             throw IllegalArgumentException(
27533bc51b9SAriel Constenla-Haile                 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid attachment file URL")),
276ae77b8caSAriel Constenla-Haile                 static_cast<XMailClient*>(this),
277cdf0e10cSrcweir                 1);
278ae77b8caSAriel Constenla-Haile 
279cdf0e10cSrcweir         rCommandArgs.push_back(ATTACH);
280ae77b8caSAriel Constenla-Haile         rCommandArgs.push_back( quoteString( sysPath ) );
281ae77b8caSAriel Constenla-Haile     }
282ae77b8caSAriel Constenla-Haile 
283ae77b8caSAriel Constenla-Haile     rtl::OUString body = xMailMessage->getBody();
284ae77b8caSAriel Constenla-Haile     if (body.getLength()>0)
285ae77b8caSAriel Constenla-Haile     {
286ae77b8caSAriel Constenla-Haile         rCommandArgs.push_back(BODY);
287ae77b8caSAriel Constenla-Haile         rCommandArgs.push_back( quoteAndEscape( body ) );
288ae77b8caSAriel Constenla-Haile     }
289ae77b8caSAriel Constenla-Haile 
290ae77b8caSAriel Constenla-Haile     rtl::OUString subject = xMailMessage->getSubject();
291ae77b8caSAriel Constenla-Haile     if (subject.getLength() > 0)
292ae77b8caSAriel Constenla-Haile     {
293ae77b8caSAriel Constenla-Haile         rCommandArgs.push_back(SUBJECT);
294ae77b8caSAriel Constenla-Haile         rCommandArgs.push_back( quoteAndEscape( subject ) );
295cdf0e10cSrcweir     }
296ae77b8caSAriel Constenla-Haile 
297cdf0e10cSrcweir     if (!(aFlag & NO_USER_INTERFACE))
298ae77b8caSAriel Constenla-Haile         rCommandArgs.push_back(FLAG_MAPI_DIALOG);
299cdf0e10cSrcweir 
300cdf0e10cSrcweir     if (!(aFlag & NO_LOGON_DIALOG))
301ae77b8caSAriel Constenla-Haile         rCommandArgs.push_back(FLAG_MAPI_LOGON_UI);
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
sendMailMessage(const Reference<XMailMessage> & xMailMessage,sal_Int32 aFlag)304ae77b8caSAriel Constenla-Haile void SAL_CALL WinSysMailClient::sendMailMessage(
305ae77b8caSAriel Constenla-Haile     const Reference<XMailMessage>& xMailMessage,
306ae77b8caSAriel Constenla-Haile     sal_Int32 aFlag)
307cdf0e10cSrcweir     throw (IllegalArgumentException, Exception, RuntimeException)
308ae77b8caSAriel Constenla-Haile {
309ae77b8caSAriel Constenla-Haile     validateParameter(xMailMessage, aFlag);
310ae77b8caSAriel Constenla-Haile 
311ae77b8caSAriel Constenla-Haile     StringList_t senddocParams;
312ae77b8caSAriel Constenla-Haile     assembleCommandLine(xMailMessage, aFlag, senddocParams);
313cdf0e10cSrcweir 
314cdf0e10cSrcweir     if (!executeSenddoc(senddocParams))
315cdf0e10cSrcweir         throw Exception(
31633bc51b9SAriel Constenla-Haile             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Send email failed")),
317ae77b8caSAriel Constenla-Haile             static_cast<XMailClient*>(this));
318cdf0e10cSrcweir }
319cdf0e10cSrcweir 
validateParameter(const Reference<XMailMessage> & xMailMessage,sal_Int32 aFlag)320ae77b8caSAriel Constenla-Haile void WinSysMailClient::validateParameter(
321ae77b8caSAriel Constenla-Haile     const Reference<XMailMessage>& xMailMessage,
322ae77b8caSAriel Constenla-Haile     sal_Int32 aFlag )
323cdf0e10cSrcweir {
324ae77b8caSAriel Constenla-Haile     if (!xMailMessage.is())
325cdf0e10cSrcweir         throw IllegalArgumentException(
32633bc51b9SAriel Constenla-Haile             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Empty mail message reference")),
327ae77b8caSAriel Constenla-Haile             static_cast<XMailClient*>(this),
328cdf0e10cSrcweir             1);
329ae77b8caSAriel Constenla-Haile 
330ae77b8caSAriel Constenla-Haile     // #93077#
331cdf0e10cSrcweir     OSL_ENSURE(!(aFlag & NO_LOGON_DIALOG), "Flag NO_LOGON_DIALOG has currently no effect");
332ae77b8caSAriel Constenla-Haile 
333cdf0e10cSrcweir     // check the flags, the allowed range is 0 - (2^n - 1)
334cdf0e10cSrcweir     if (aFlag < 0 || aFlag > 3)
335cdf0e10cSrcweir         throw IllegalArgumentException(
33633bc51b9SAriel Constenla-Haile             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid flag value")),
337ae77b8caSAriel Constenla-Haile             static_cast<XMailClient*>(this),
338cdf0e10cSrcweir             2);
339cdf0e10cSrcweir 
340cdf0e10cSrcweir     // check if a recipient is specified of the flags NO_USER_INTERFACE is specified
341ae77b8caSAriel Constenla-Haile     if ((aFlag & NO_USER_INTERFACE) && !xMailMessage->getRecipient().getLength())
342cdf0e10cSrcweir         throw IllegalArgumentException(
34333bc51b9SAriel Constenla-Haile             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No recipient specified")),
344ae77b8caSAriel Constenla-Haile             static_cast<XMailClient*>(this),
345cdf0e10cSrcweir             1);
346cdf0e10cSrcweir }
347ae77b8caSAriel Constenla-Haile 
348ae77b8caSAriel Constenla-Haile }
349