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