|
From: Marco N. <th...@ti...> - 2003-04-02 15:58:44
|
You can use a MAPI function called MAPISendMail to send mail with your
default profile in your default email client (ie Outlook Express). Remember
to link mapi32.dll to your project (-lmapi32 in linker options).
#include <windows.h>
#include <mapi.h>
int main (int argc, char **argv) {
MapiMessage Mex;
MapiRecipDesc To;
ULONG res;
To.ulReserved=0;
To.ulRecipClass=MAPI_TO;
To.lpszName = (LPTSTR) GlobalAlloc (GPTR, 100);
lstrcpy (To.lpszName, "Someone");
To.lpszAddress = (LPTSTR) GlobalAlloc (GPTR, 100);
lstrcpy (To.lpszAddress, "so...@so...");
To.ulEIDSize=0;
To.lpEntryID=NULL;
Mex.ulReserved=0;
Mex.lpszSubject = (LPTSTR) GlobalAlloc (GPTR, 100);
lstrcpy (Mex.lpszSubject, "Hello world!");
Mex.lpszNoteText = (LPTSTR) GlobalAlloc (GPTR, 100);
lstrcpy (Mex.lpszNoteText, "This is an e-mail.\n");
Mex.lpszMessageType = NULL;
Mex.lpszDateReceived = NULL;
Mex.lpszConversationID = NULL;
Mex.flFlags = 0;
Mex.lpOriginator = NULL;
Mex.nRecipCount = 1;
Mex.lpRecips = &To;
Mex.nFileCount = 0;
Mex.lpFiles = NULL;
res=MAPISendMail (0, 0, &Mex, MAPI_NEW_SESSION, 0);
return 0;
}
|