Version: 0.6.0
smapi.h
1 // Name: smapi.h
3 // Purpose: Simple MAPI classes
4 // Author: PJ Naughter <pjna@naughter.com>
5 // Modified by: Julian Smart
6 // Created: 2001-08-21
7 // RCS-ID: $Id$
8 // Copyright: (c) PJ Naughter
9 // Licence: wxWindows licence
11 #pragma once
12 
13 #include "wxgis/net/net.h"
14 #include "wxgis/net/message.h"
15 
16 #include "wxgisdefs.h"
17 
18 #ifdef wxGIS_USE_EMAIL
19 
20 #ifdef __WINDOWS__
21 
22 #ifdef __CYGWIN__
23  #include <w32api/mapi.h>
24 #else
25  #include <mapi.h>
26 #endif
27 
28 class wxMapiData
29 {
30 public:
31  wxMapiData()
32  {
33  m_hSession = 0;
34  m_nLastError = 0;
35  m_hMapi = NULL;
36  m_lpfnMAPILogon = NULL;
37  m_lpfnMAPILogoff = NULL;
38  m_lpfnMAPISendMail = NULL;
39  m_lpfnMAPIResolveName = NULL;
40  m_lpfnMAPIFreeBuffer = NULL;
41  }
42 
43  //Data
44  LHANDLE m_hSession; //Mapi Session handle
45  long m_nLastError; //Last Mapi error value
46  HINSTANCE m_hMapi; //Instance handle of the MAPI dll
47  LPMAPILOGON m_lpfnMAPILogon; //MAPILogon function pointer
48  LPMAPILOGOFF m_lpfnMAPILogoff; //MAPILogoff function pointer
49  LPMAPISENDMAIL m_lpfnMAPISendMail; //MAPISendMail function pointer
50  LPMAPIRESOLVENAME m_lpfnMAPIResolveName; //MAPIResolveName function pointer
51  LPMAPIFREEBUFFER m_lpfnMAPIFreeBuffer; //MAPIFreeBuffer function pointer
52 };
53 
54 
55 //The class which encapsulates the MAPI connection
56 class wxMapiSession
57 {
58 public:
59  //Constructors / Destructors
60  wxMapiSession(void);
61  ~wxMapiSession(void);
62 
63  //Logon / Logoff Methods
64  bool Logon(const wxString& sProfileName, const wxString& sPassword = wxEmptyString, wxWindow* pParentWnd = NULL);
65  bool LoggedOn() const;
66  bool Logoff();
67 
68  //Send a message
69  bool Send(const wxMailMessage& message);
70 
71  //General MAPI support
72  bool MapiInstalled() const;
73 
74  //Error Handling
75  long GetLastError() const;
76 
77 protected:
78  //Methods
79  void Initialise();
80  void Deinitialise();
81 
82  wxMapiData* m_data;
83 };
84 
85 #endif //__WINDOWS__
86 
87 #endif //wxGIS_USE_EMAIL