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>
30 #pragma warning(push, 1)
37 #include <osl/file.hxx>
39 //--------------------------------------------------------------
41 //--------------------------------------------------------------
43 using namespace ::rtl
;
44 using namespace ::cppu
;
45 using namespace ::com::sun::star::uno
;
46 using namespace ::com::sun::star::lang
;
48 using namespace com::sun::star::system
;
50 #define RDB_SYSPATH "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\applicat.rdb"
52 //--------------------------------------------------------------
54 //--------------------------------------------------------------
56 Reference
< XMultiServiceFactory
> g_xFactory
;
58 //--------------------------------------------------------------
60 //--------------------------------------------------------------
63 // int SAL_CALL main(int nArgc, char* Argv[], char* pEnv[] )
64 // make Warning free, leave out typename
65 int SAL_CALL
main(int , char*, char* )
67 //-------------------------------------------------
68 // get the global service-manager
69 //-------------------------------------------------
71 // Get global factory for uno services.
72 OUString rdbName
= OUString( RDB_SYSPATH
);
73 Reference
< XMultiServiceFactory
> g_xFactory( createRegistryServiceFactory( rdbName
) );
75 // Print a message if an error occurred.
76 if ( g_xFactory
.is() == sal_False
)
78 OSL_FAIL("Can't create RegistryServiceFactory");
82 printf("Creating RegistryServiceFactory successful\n");
84 //-------------------------------------------------
85 // try to get an Interface to a XFilePicker Service
86 //-------------------------------------------------
90 Reference
< XSimpleMailClientSupplier
> xSmplMailClientSuppl(
91 g_xFactory
->createInstance( OUString("com.sun.star.system.SimpleSystemMail") ), UNO_QUERY
);
93 if ( !xSmplMailClientSuppl
.is() )
95 OSL_FAIL( "Error creating SimpleSystemMail Service" );
99 Reference
< XSimpleMailClient
> xSmplMailClient(
100 xSmplMailClientSuppl
->querySimpleMailClient( ) );
102 if ( xSmplMailClient
.is( ) )
104 Reference
< XSimpleMailMessage
> xSmplMailMsg(
105 xSmplMailClient
->createSimpleMailMessage( ) );
107 if ( xSmplMailMsg
.is( ) )
109 xSmplMailMsg
->setRecipient( OUString("tino.rachui@germany.sun.com") );
110 xSmplMailMsg
->setOriginator( OUString("tino.rachui@germany.sun.com") );
112 Sequence
< OUString
> ccRecips( 1 );
113 ccRecips
[0] = OUString("tino.rachui@germany.sun.com");
115 xSmplMailMsg
->setCcRecipient( ccRecips
);
117 Sequence
< OUString
> bccRecips( 1 );
118 bccRecips
[0] = OUString("tino.rachui@germany.sun.com");
120 xSmplMailMsg
->setBccRecipient( bccRecips
);
122 xSmplMailMsg
->setSubject( OUString("Mapi Test") );
124 Sequence
< OUString
> attachements( 2 );
126 OUString
aFile("D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\testprx.exe");
129 osl::FileBase::getFileURLFromSystemPath( aFile
, aFileURL
);
130 attachements
[0] = aFileURL
;
132 aFile
= OUString("D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\testsyssh.exe");
133 osl::FileBase::getFileURLFromSystemPath( aFile
, aFileURL
);
135 attachements
[1] = aFile
;
137 xSmplMailMsg
->setAttachement( attachements
);
139 xSmplMailClient
->sendSimpleMailMessage( xSmplMailMsg
, 0 );
147 //--------------------------------------------------
149 //--------------------------------------------------
151 // Cast factory to XComponent
152 Reference
< XComponent
> xComponent( g_xFactory
, UNO_QUERY
);
154 // Print a message if an error occurred.
155 if ( xComponent
.is() == sal_False
)
157 OSL_FAIL("Error shuting down");
160 // Dispose and clear factory
161 xComponent
->dispose();
163 g_xFactory
= Reference
< XMultiServiceFactory
>();
165 printf("Test successful\n");
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */