1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| typedef ULONG (FAR PASCAL *MAPIFUNC) (LHANDLE lhSession, ULONG ulUIParam,
lpMapiMessage lpMessage, FLAGS flFlags,
ULONG ulReserved);
int _tmain(int , _TCHAR* [])
{
const HINSTANCE hMAPILib = ::LoadLibrary(_T("MAPI32.DLL"));
if (hMAPILib)
{
MAPIFUNC lpMAPISendMail = (MAPIFUNC) GetProcAddress(hMAPILib, "MAPISendMail");
if (lpMAPISendMail != NULL)
{
static MapiMessage Msg;
memset(&Msg, 0, sizeof(Msg));
MapiFileDesc desc =
{
0, /* Reserved for future use (must be 0) */
0, /* Flags */
0, /* character in text to be replaced by attachment */
"d:\\classeur1.XLS", /* Full path name of attachment file */
NULL, /* Original file name (optional) */
NULL /* Attachment file type (can be lpMapiFileTagExt) */
} ;
Msg.lpszSubject = "Put subject text here";
Msg.lpszNoteText = "Put message text here";
Msg.nFileCount = 1;
Msg.lpFiles = &desc;
lpMAPISendMail(NULL, NULL, &Msg, (FLAGS) (MAPI_LOGON_UI | MAPI_DIALOG), 0);
}
VERIFY(::FreeLibrary(hMAPILib));
}
return 1;
} |
Partager