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 #ifndef INCLUDED_SIMPLEMAPI_HXX 23 #define INCLUDED_SIMPLEMAPI_HXX 24 25 #define WIN32_LEAN_AND_MEAN 26 #if defined _MSC_VER 27 #pragma warning(push, 1) 28 #endif 29 #include <windows.h> 30 #include <mapi.h> 31 // Extended MAPI left the Windows SDK after Platform SDK v7.0 -- Microsoft moved 32 // it to Outlook -- so a modern SDK has no mapix.h, and none of its four 33 // companions either. Nothing here needs them: this module uses only simple 34 // MAPI (MAPILogon, MAPISendMail, MAPILogoff, and the Mapi* structures and 35 // MAPI_* flags), all of which mapi.h still declares. 36 // 37 // Dropped rather than sourced from the old SDK on purpose. Putting v7.0's 38 // include directory on the path pulls in its wtypes.h behind mapix.h, and that 39 // then collides with the modern SDK's -- C2011 on every COM type in it. The 40 // two header trees do not mix inside one translation unit. 41 #if !defined __MINGW32__ && !(defined _MSC_VER && _MSC_VER >= 1900) 42 #include <mapix.h> 43 #endif 44 #if defined _MSC_VER 45 #pragma warning(pop) 46 #endif 47 48 namespace shell 49 { 50 class WinSysMapi 51 { 52 public: 53 /** 54 @throws std::runtime_error 55 if either the mapi32.dll could not be loaded at all 56 or necessary function exports are missing 57 */ 58 WinSysMapi(); // throws std::runtime_error; 59 60 ~WinSysMapi(); 61 62 ULONG MAPILogon( 63 ULONG ulUIParam, 64 LPTSTR lpszProfileName, 65 LPTSTR lpszPassword, 66 FLAGS flFlags, 67 ULONG ulReserved, 68 LPLHANDLE lplhSession ); 69 70 ULONG MAPILogoff( 71 LHANDLE lhSession, 72 ULONG ulUIParam, 73 FLAGS flFlags, 74 ULONG ulReserved ); 75 76 ULONG MAPISendMail( 77 LHANDLE lhSession, 78 ULONG ulUIParam, 79 lpMapiMessage lpMessage, 80 FLAGS flFlags, 81 ULONG ulReserved ); 82 83 private: 84 HMODULE m_hMapiDll; 85 LPMAPILOGON m_lpfnMapiLogon; 86 LPMAPILOGOFF m_lpfnMapiLogoff; 87 LPMAPISENDMAIL m_lpfnMapiSendMail; 88 }; 89 } 90 #endif 91