1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/lang/XComponent.hpp>
21 #include <com/sun/star/registry/XSimpleRegistry.hpp>
22 #include <com/sun/star/system/XSimpleMailClientSupplier.hpp>
23 #include <cppuhelper/servicefactory.hxx>
24 #include <rtl/ustring.hxx>
25 #include <sal/types.h>
26 #include <osl/diagnose.h>
32 #include <osl/file.hxx>
38 using namespace ::cppu
;
39 using namespace ::com::sun::star::uno
;
40 using namespace ::com::sun::star::lang
;
42 using namespace com::sun::star::system
;
44 #define RDB_SYSPATH "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\applicat.rdb"
50 Reference
< XMultiServiceFactory
> g_xFactory
;
56 // int SAL_CALL main(int nArgc, char* Argv[], char* pEnv[] )
57 // make Warning free, leave out typename
58 int SAL_CALL
main(int , char*, char* )
61 // get the global service-manager
64 // Get global factory for uno services.
65 OUString rdbName
= OUString( RDB_SYSPATH
);
66 Reference
< XMultiServiceFactory
> g_xFactory( createRegistryServiceFactory( rdbName
) );
68 // Print a message if an error occurred.
69 if ( g_xFactory
.is() == sal_False
)
71 OSL_FAIL("Can't create RegistryServiceFactory");
75 printf("Creating RegistryServiceFactory successful\n");
78 // try to get an Interface to a XFilePicker Service
83 Reference
< XSimpleMailClientSupplier
> xSmplMailClientSuppl(
84 g_xFactory
->createInstance("com.sun.star.system.SimpleSystemMail"), UNO_QUERY
);
86 if ( !xSmplMailClientSuppl
.is() )
88 OSL_FAIL( "Error creating SimpleSystemMail Service" );
92 Reference
< XSimpleMailClient
> xSmplMailClient(
93 xSmplMailClientSuppl
->querySimpleMailClient( ) );
95 if ( xSmplMailClient
.is( ) )
97 Reference
< XSimpleMailMessage
> xSmplMailMsg(
98 xSmplMailClient
->createSimpleMailMessage( ) );
100 if ( xSmplMailMsg
.is( ) )
102 xSmplMailMsg
->setRecipient( OUString("tino.rachui@germany.sun.com") );
103 xSmplMailMsg
->setOriginator( OUString("tino.rachui@germany.sun.com") );
105 Sequence
<OUString
> ccRecips
{ "tino.rachui@germany.sun.com" };
107 xSmplMailMsg
->setCcRecipient( ccRecips
);
109 Sequence
<OUString
> bccRecips
{ "tino.rachui@germany.sun.com" };
111 xSmplMailMsg
->setBccRecipient( bccRecips
);
113 xSmplMailMsg
->setSubject( OUString("Mapi Test") );
115 Sequence
< OUString
> attachments( 2 );
117 OUString
aFile("D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\testprx.exe");
120 osl::FileBase::getFileURLFromSystemPath( aFile
, aFileURL
);
121 attachments
[0] = aFileURL
;
123 aFile
= "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\testsyssh.exe";
124 osl::FileBase::getFileURLFromSystemPath( aFile
, aFileURL
);
126 attachments
[1] = aFile
;
128 xSmplMailMsg
->setAttachement( attachments
);
130 xSmplMailClient
->sendSimpleMailMessage( xSmplMailMsg
, 0 );
142 // Cast factory to XComponent
143 Reference
< XComponent
> xComponent( g_xFactory
, UNO_QUERY
);
145 // Print a message if an error occurred.
146 if ( xComponent
.is() == sal_False
)
148 OSL_FAIL("Error shutting down");
151 // Dispose and clear factory
152 xComponent
->dispose();
155 printf("Test successful\n");
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */