Link to home
Start Free TrialLog in
Avatar of paulsat
paulsatFlag for United States of America

asked on

Sending EMail from C/C++

Does anyone know how to send an EMail message from a C/C++ Windows Application, given the recipient's EMail address, the subject for the EMail, the message text of the EMail, and a possible attachment file.

I need to know how to find the user's login ID and password for the user's EMail account if that info is available from the registry or whatever as I assume you would need that to send the message?
ASKER CERTIFIED SOLUTION
Avatar of naveenkohli
naveenkohli

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of paulsat

ASKER

What is MAPI and what libraries will I need to link against? Also will this work for regardless of what the user uses for his/her default EMail application and will it work under WIndows NT v4 or greater, Win95, and Win98?
Avatar of naveenkohli
naveenkohli

MAPI is messaging API. Its used for creating messaging applications. For more information, i will suggest that you read on line documentation in Platform SDK.
You will need following header files ...

#include <mapi.h>                        // MAPI Header file.
#include <mapix.h>
#include <malloc.h>

// If compiling for 32 bit platforms we will use MAPI32.DLL
// If compiling for 16 bit platforms we will use MAPI.DLL
#ifdef _WIN32
#define szMAPIDLL                  "MAPI32.DLL"
#define szMAPIXDLL                  "MAPIX32.DLL"
#else
#define szMAPIDLL                  "MAPI.DLL"
#define szMAPIXDLL                  "MAPIX.DLL"
#endif

The way i implemented, depending on the type of environement (16/32 bit) i am loading the required libs at run time.

LoadLibrary (szMAPIDLL);

It works on all platforms.

using the folowing function, you can check if MAPI isinsyalled on your system or not. Which normally is ;))
Avatar of paulsat

ASKER

Much Thanks!  You know, I'm a seasoned Macintosh programmer (13 years) and have been doing cross platform stuff (Windows to me) for many, many years as well.  I find the biggest problem with Windows is where to look for and find the documentation for what you want to do.