发送邮件的问题

别以为你站在珠峰就能看到全世界 别以为你站在珠峰就能看到全世界 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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的网站的
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部