merge the formfield patch from ooo-build
[ooovba.git] / shell / source / win32 / simplemail / simplemapi.cxx
blobc0f4a6bdb9ed9c5a2a03556eb9eaf0dc146ddb82
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: simplemapi.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_shell.hxx"
33 #include "simplemapi.hxx"
35 #include <string>
36 #include <stdexcept>
38 CSimpleMapi::CSimpleMapi() :
39 m_lpfnMapiLogon(NULL),
40 m_lpfnMapiLogoff(NULL),
41 m_lpfnMapiSendMail(NULL)
43 m_hMapiDll = LoadLibrary("mapi32.dll");
44 if ((m_hMapiDll == INVALID_HANDLE_VALUE) || (m_hMapiDll == NULL))
45 throw std::runtime_error("Couldn't load MAPI library");
47 m_lpfnMapiLogon = reinterpret_cast<LPMAPILOGON>(GetProcAddress(m_hMapiDll, "MAPILogon"));
48 if (!m_lpfnMapiLogon)
49 throw std::runtime_error("Couldn't find method MAPILogon");
51 m_lpfnMapiLogoff = reinterpret_cast<LPMAPILOGOFF>(GetProcAddress(m_hMapiDll, "MAPILogoff"));
52 if (!m_lpfnMapiLogoff)
53 throw std::runtime_error("Couldn't find method MAPILogoff");
55 m_lpfnMapiSendMail = reinterpret_cast<LPMAPISENDMAIL>(GetProcAddress(m_hMapiDll, "MAPISendMail"));
56 if (!m_lpfnMapiSendMail)
57 throw std::runtime_error("Couldn't find method MAPISendMail");
60 CSimpleMapi::~CSimpleMapi()
62 FreeLibrary(m_hMapiDll);
65 ULONG CSimpleMapi::MAPILogon(
66 ULONG ulUIParam,
67 LPTSTR lpszProfileName,
68 LPTSTR lpszPassword,
69 FLAGS flFlags,
70 ULONG ulReserved,
71 LPLHANDLE lplhSession )
73 return m_lpfnMapiLogon(
74 ulUIParam,
75 lpszProfileName,
76 lpszPassword,
77 flFlags,
78 ulReserved,
79 lplhSession );
82 ULONG CSimpleMapi::MAPILogoff(
83 LHANDLE lhSession,
84 ULONG ulUIParam,
85 FLAGS flFlags,
86 ULONG ulReserved )
88 return m_lpfnMapiLogoff(lhSession, ulUIParam, flFlags, ulReserved);
91 ULONG CSimpleMapi::MAPISendMail(
92 LHANDLE lhSession,
93 ULONG ulUIParam,
94 lpMapiMessage lpMessage,
95 FLAGS flFlags,
96 ULONG ulReserved )
98 return m_lpfnMapiSendMail(lhSession, ulUIParam, lpMessage, flFlags, ulReserved);