1 ///////////////////////////////////////////////////////////////////////////////
\r
5 // Desc: This class encapsulates the MAPI and CMC mail functions.
\r
7 // Copyright (c) 2003 Michael Carruth
\r
9 ///////////////////////////////////////////////////////////////////////////////
\r
13 #include <xcmc.h> // CMC function defs
\r
14 #include <mapi.h> // MAPI function defs
\r
16 #ifndef TStrStrVector
\r
17 // STL generates various warnings.
\r
18 // 4100: unreferenced formal parameter
\r
19 // 4663: C++ language change: to explicitly specialize class template...
\r
20 // 4018: signed/unsigned mismatch
\r
21 // 4245: conversion from <a> to <b>: signed/unsigned mismatch
\r
22 #pragma warning(push, 3)
\r
23 #pragma warning(disable: 4100)
\r
24 #pragma warning(disable: 4663)
\r
25 #pragma warning(disable: 4018)
\r
26 #pragma warning(disable: 4245)
\r
28 #pragma warning(pop)
\r
30 typedef std::pair<string,string> TStrStrPair;
\r
31 typedef std::vector<TStrStrPair> TStrStrVector;
\r
32 #endif // !defined TStrStrVector
\r
35 // Define CMC entry points
\r
37 typedef CMC_return_code (FAR PASCAL *LPCMCLOGON) \
\r
38 (CMC_string, CMC_string, CMC_string, CMC_object_identifier, \
\r
39 CMC_ui_id, CMC_uint16, CMC_flags, CMC_session_id FAR*, \
\r
40 CMC_extension FAR*);
\r
42 typedef CMC_return_code (FAR PASCAL *LPCMCSEND) \
\r
43 (CMC_session_id, CMC_message FAR*, CMC_flags, \
\r
44 CMC_ui_id, CMC_extension FAR*);
\r
46 typedef CMC_return_code (FAR PASCAL *LPCMCLOGOFF) \
\r
47 (CMC_session_id, CMC_ui_id, CMC_flags, CMC_extension FAR*);
\r
49 typedef CMC_return_code (FAR PASCAL *LPCMCQUERY) \
\r
50 (CMC_session_id, CMC_enum, CMC_buffer, CMC_extension FAR*);
\r
53 ////////////////////////////// Class Definitions /////////////////////////////
\r
55 // ===========================================================================
\r
58 // See the module comment at top of file.
\r
64 virtual ~CMailMsg();
\r
66 //-----------------------------------------------------------------------------
\r
68 // Sets the Email:To address
\r
72 // sName Optional name
\r
75 // CMailMsg reference
\r
78 // Only one To address can be set. If called more than once
\r
79 // the last address will be used.
\r
84 string sName = _T("")
\r
87 //-----------------------------------------------------------------------------
\r
89 // Sets the Email:Cc address
\r
93 // sName Optional name
\r
96 // CMailMsg reference
\r
99 // Multiple Cc addresses can be set.
\r
104 string sName = _T("")
\r
107 //-----------------------------------------------------------------------------
\r
109 // Sets the Email:Bcc address
\r
112 // sAddress Address
\r
113 // sName Optional name
\r
116 // CMailMsg reference
\r
119 // Multiple Bcc addresses can be set.
\r
124 string sName = _T("")
\r
127 //-----------------------------------------------------------------------------
\r
129 // Sets the Email:From address
\r
132 // sAddress Address
\r
133 // sName Optional name
\r
136 // CMailMsg reference
\r
139 // Only one From address can be set. If called more than once
\r
140 // the last address will be used.
\r
145 string sName = _T("")
\r
148 //-----------------------------------------------------------------------------
\r
150 // Sets the Email:Subject
\r
153 // sSubject Subject
\r
156 // CMailMsg reference
\r
164 ) {m_sSubject = sSubject; return *this;};
\r
166 //-----------------------------------------------------------------------------
\r
168 // Sets the Email message body
\r
171 // sMessage Message body
\r
174 // CMailMsg reference
\r
182 ) {m_sMessage = sMessage; return *this;};
\r
184 //-----------------------------------------------------------------------------
\r
186 // Attaches a file to the email
\r
189 // sAttachment Fully qualified file name
\r
190 // sTitle File display name
\r
193 // CMailMsg reference
\r
200 string sAttachment,
\r
201 string sTitle = _T("")
\r
204 //-----------------------------------------------------------------------------
\r
212 // TRUE if successful
\r
215 // First simple MAPI is used if unsuccessful CMC is used.
\r
221 //-----------------------------------------------------------------------------
\r
223 // Send email using CMC functions.
\r
229 // TRUE if successful
\r
236 //-----------------------------------------------------------------------------
\r
238 // Send email using MAPI functions.
\r
244 // -1: cancelled; 0: other failure; 1: success
\r
251 //-----------------------------------------------------------------------------
\r
253 // Initialize MAPI32.dll
\r
259 // TRUE if successful
\r
266 //-----------------------------------------------------------------------------
\r
268 // Uninitialize MAPI32.dll
\r
279 void Uninitialize();
\r
282 +------------------------------------------------------------------------------
\r
284 | Function: cResolveName()
\r
286 | Parameters: [IN] lpszName = Name of e-mail recipient to resolve.
\r
287 | [OUT] ppRecips = Pointer to a pointer to an lpMapiRecipDesc
\r
289 | Purpose: Resolves an e-mail address and returns a pointer to a
\r
290 | MapiRecipDesc structure filled with the recipient information
\r
291 | contained in the address book.
\r
293 | Note: ppRecips is allocated off the heap using MAPIAllocateBuffer.
\r
294 | Any user of this method must be sure to release ppRecips when
\r
295 | done with it using either MAPIFreeBuffer or cFreeBuffer.
\r
296 +-------------------------------------------------------------------------------
\r
298 int cResolveName( LHANDLE m_lhSession, const char * lpszName, lpMapiRecipDesc *ppRecip );
\r
300 TStrStrVector m_from; // From <address,name>
\r
301 TStrStrVector m_to; // To <address,name>
\r
302 TStrStrVector m_cc; // Cc <address,name>
\r
303 TStrStrVector m_bcc; // Bcc <address,name>
\r
304 TStrStrVector m_attachments; // Attachment <file,title>
\r
305 string m_sSubject; // EMail subject
\r
306 string m_sMessage; // EMail message
\r
308 HMODULE m_hMapi; // Handle to MAPI32.DLL
\r
309 LPCMCQUERY m_lpCmcQueryConfiguration; // Cmc func pointer
\r
310 LPCMCLOGON m_lpCmcLogon; // Cmc func pointer
\r
311 LPCMCSEND m_lpCmcSend; // Cmc func pointer
\r
312 LPCMCLOGOFF m_lpCmcLogoff; // Cmc func pointer
\r
313 LPMAPILOGON m_lpMapiLogon; // Mapi func pointer
\r
314 LPMAPISENDMAIL m_lpMapiSendMail; // Mapi func pointer
\r
315 LPMAPILOGOFF m_lpMapiLogoff; // Mapi func pointer
\r
316 LPMAPIRESOLVENAME m_lpMapiResolveName; // Mapi func pointer
\r
317 LPMAPIFREEBUFFER m_lpMapiFreeBuffer; // Mapi func pointer
\r
319 BOOL m_bReady; // MAPI is loaded
\r