1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: simplemapi.cxx,v $
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"
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"));
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(
67 LPTSTR lpszProfileName
,
71 LPLHANDLE lplhSession
)
73 return m_lpfnMapiLogon(
82 ULONG
CSimpleMapi::MAPILogoff(
88 return m_lpfnMapiLogoff(lhSession
, ulUIParam
, flFlags
, ulReserved
);
91 ULONG
CSimpleMapi::MAPISendMail(
94 lpMapiMessage lpMessage
,
98 return m_lpfnMapiSendMail(lhSession
, ulUIParam
, lpMessage
, flFlags
, ulReserved
);