分类: C/C++
2008-08-25 18:32:27
CMapi
, 2 simple classes to encapsulate sending mail using Simple MAPI.
Simple MAPI is a set of functions exported by MAPI32.dll which allows you to send and receive mail in a transport independent way. It is an optional part of all Win32 operating systems since Windows 95 (excluding Windows CE). MAPI is intended more for the corporate environment when compared with the Internet mail standard SMTP e.g. products such as MS Exchange Server use MAPI extensively. Transport providers are available for a number of messaging transports including Exchange Server, SMTP, Fax, cc:Mail CompuServe etc. To be able to specify different transports, MAPI provides the concept of profiles which are setup using the Mail control panel applet.
GetProcAddress()
calls.
#include cmapi.h
in which ever of your modules needs to make calls to the classes.
mapi.h
to your pre compiled header to improve compilation speed. An build message will inform you of this.
InitInstance()
in the module app.cpp.
V1.0 (14th May 1999)
V1.01 (5 December 1999)
CMapi
is used in a console app which was giving an ASSERT.
The API consists of the following 2 classes and their methods and variables:
CMapiMessage:
CMapiSession:
CStringArray
and contains the array of recipients which the email will be Carbon Copied to. The way addresses are specified is the same as for m_To.
CStringArray
and contains the array of recipients which the email will be Blind Carbon Copied to. The way addresses are specified is the same as for m_To.
CString
and is the subject line of the email.
CString
and is the body of the email.
CStringArray
and is a list of filenames to be included as attachments in the email.
CStringArray
and contains the titles of what each file attachment will be known as to recipients of this message. If you leave this array empty then the title will be the same as the filename. As an example have a look at the code in InitInstance()
in app.cpp to see how the autoexec.bat attachment has a title of my autoexec.bat.
Remarks:
Standard constructor for the class. This class is the main MAPI support class and contains the functions to actually send the mail message.
Remarks:
Standard desstructor for the class. Internally this logs you out of MAPI if you're logged in and unloads the MAPI dll.
Return Value:
TRUE if you were successfully logged in to MAPI otherwise FALSE.
Parameters:
Remarks:
Logons to the MAPI messaging system creating a session with it. If you pass an empty profile name then Logon will try to interactively logon by presenting the normal MAPI logon dialog. Specifying NULL as the parent window as is the default will use the window as returned by AfxGetMainWnd()
. Please note that you must be logged on to MAPI prior to sending a message. Internally the code will ASSERT
to ensure you do not forget to do this.
Remarks:
Simply accessor which returns TRUE if this instance is logged on to MAPI otherwise FALSE.
Return Value:
TRUE if you were successfully logged of from MAPI otherwise FALSE.
Remarks:
The corollary function to Logon. Internally this function is called in the CMapiSession
destructor.
Return Value:
TRUE if the message was successfully sent otherwise FALSE.
Parameters:
Remarks:
Sends the message as specfied in the "message" parameter, using the MAPI profile currently logged into.
Remarks:
Simply accessor which returns TRUE if MAPI is installed and has been correctly initialised ready for this instance to use. The actual loading of the MAPI dll is handled internally by the CMapiSession
constructor, meaning it is valid this function anytime after you have constructed a CMapiSession
instance.
Return Value:
The last MAPI error generated by this CMapiSession instance.
Remarks:
Since the class uses MAPI which has its own way of reporting errors different to the standard Win32 way (GetLastError()
), this method allows this value to be retreived. MAPI errors are documented in the MAPI.h file in your VC include directory.
PJ Naughter
Email:
Web:
5 December 1999