1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_shell.hxx" 26 #include "simplemapi.hxx" 27 28 #include <string> 29 #include <stdexcept> 30 31 CSimpleMapi::CSimpleMapi() : 32 m_lpfnMapiLogon(NULL), 33 m_lpfnMapiLogoff(NULL), 34 m_lpfnMapiSendMail(NULL) 35 { 36 m_hMapiDll = LoadLibrary("mapi32.dll"); 37 if ((m_hMapiDll == INVALID_HANDLE_VALUE) || (m_hMapiDll == NULL)) 38 throw std::runtime_error("Couldn't load MAPI library"); 39 40 m_lpfnMapiLogon = reinterpret_cast<LPMAPILOGON>(GetProcAddress(m_hMapiDll, "MAPILogon")); 41 if (!m_lpfnMapiLogon) 42 throw std::runtime_error("Couldn't find method MAPILogon"); 43 44 m_lpfnMapiLogoff = reinterpret_cast<LPMAPILOGOFF>(GetProcAddress(m_hMapiDll, "MAPILogoff")); 45 if (!m_lpfnMapiLogoff) 46 throw std::runtime_error("Couldn't find method MAPILogoff"); 47 48 m_lpfnMapiSendMail = reinterpret_cast<LPMAPISENDMAIL>(GetProcAddress(m_hMapiDll, "MAPISendMail")); 49 if (!m_lpfnMapiSendMail) 50 throw std::runtime_error("Couldn't find method MAPISendMail"); 51 } 52 53 CSimpleMapi::~CSimpleMapi() 54 { 55 FreeLibrary(m_hMapiDll); 56 } 57 58 ULONG CSimpleMapi::MAPILogon( 59 ULONG ulUIParam, 60 LPTSTR lpszProfileName, 61 LPTSTR lpszPassword, 62 FLAGS flFlags, 63 ULONG ulReserved, 64 LPLHANDLE lplhSession ) 65 { 66 return m_lpfnMapiLogon( 67 ulUIParam, 68 lpszProfileName, 69 lpszPassword, 70 flFlags, 71 ulReserved, 72 lplhSession ); 73 } 74 75 ULONG CSimpleMapi::MAPILogoff( 76 LHANDLE lhSession, 77 ULONG ulUIParam, 78 FLAGS flFlags, 79 ULONG ulReserved ) 80 { 81 return m_lpfnMapiLogoff(lhSession, ulUIParam, flFlags, ulReserved); 82 } 83 84 ULONG CSimpleMapi::MAPISendMail( 85 LHANDLE lhSession, 86 ULONG ulUIParam, 87 lpMapiMessage lpMessage, 88 FLAGS flFlags, 89 ULONG ulReserved ) 90 { 91 return m_lpfnMapiSendMail(lhSession, ulUIParam, lpMessage, flFlags, ulReserved); 92 } 93 94