发送邮件的问题
HMODULE hMod=LoadLibrary("MAPI32.DLL");
if(hMod == NULL)
{
printf("LoadLibrary fail.\n");
return ;
}
ULONG (PASCAL *lpfnSendMail) (ULONG, ULONG, MapiMessage *, FLAGS, ULONG);
(FARPROC &)lpfnSendMail=GetProcAddress(hMod, "MAPISendMail");
if(lpfnSendMail == NULL)
{
printf("GetProcAddress fail.\n");
return ;
}
MapiFileDesc attachment=
{
0, // ulReserved, must be 0
0, // no flags; this is a data file
(ULONG) - 1, // position not specified
argv[0], // pathname, if original filename is NULL, this is the filename
NULL, // original filename
NULL
}; // MapiFileTagExt unused
MapiRecipDesc recip={ 0, MAPI_TO,"nowcan", "nowcan@163.com", 0, NULL };
MapiMessage message=
{
0, // reserved, must be 0
"测试", // subject
"我在csdn的名称是\n\nBIOS测试结果见附件。", // note text
NULL, // NULL = interpersonal message
NULL, // no date; MAPISendMail ignores it
NULL, // no conversation ID
0L, // no flags, MAPISendMail ignores it
NULL, // no originator, this is ignored too
1, // recipients
&recip, // recipient array
1, // one attachment
&attachment
}; // the attachment structure
int nError=lpfnSendMail(0, 0, &message, MAPI_LOGON_UI | MAPI_DIALOG, 0);
// after returning from the MAPISendMail call, the window must
// be re-enabled and focus returned to the frame to undo the workaround
// done before the MAPI call.
if(nError != SUCCESS_SUCCESS && nError != MAPI_USER_ABORT && nError != MAPI_E_LOGIN_FAILURE)
{
printf("SendMail fail.\n");
}
FreeLibrary(hMod);
这段代码可以用来发邮件,在控制台里完全没有问题,如果普通的就会有问题,弹出来的outlook窗体不能控制,不知道什么原因,请指教,这个代码是在nowcan的网站的