【发布时间】:2016-11-21 21:02:01
【问题描述】:
我正在创建默认邮件应用程序,例如 Thunderbird 和 Outlook,但仅具有一些功能。所以现在的问题只有单词 2007 和 excel 2007 从 fileMenu -> 发送 -> 电子邮件发送文件时,单击电子邮件后应用程序崩溃,但同样的事情在 Powerpoint 2007 和一个笔记 2007 中工作。
在 Office 2007 中,MapiLogon(...) 得到第一个调用,这是我的 MAPILogOn(...),
// I have used ofstream for the log purpose.
#include <MAPIX.h>
extern "C" ULONG MAPILogon(ULONG_PTR ulUIParam, LPSTR lpszProfileName, LPSTR lpszPassword, FLAGS flFlags, ULONG ulReserved, LPLHANDLE lplhSession)
{
ofstream outfile;
outfile.open("e:\\temp\\MAPILogon.txt");
HRESULT hrs = NULL;
MAPIINIT_0 MAPIINIT = { MAPI_INIT_VERSION, MAPI_NO_COINIT };
hrs = MAPIInitialize(NULL);
lplhSession = nullptr;
if (hrs != S_OK)
{
outfile << "\n MAPI uniititalized";
}
else
{
outfile << "\n MAPI initialized";
LPMAPISESSION FAR spSession = NULL;
outfile << "\n lplhsession - " << spSession;
hrs = MAPILogonEx(NULL, "Outlook", NULL, MAPI_EXTENDED | MAPI_NEW_SESSION, &spSession);
if (hrs == NULL)
{
outfile << "\n MAPI problem while log in." << spSession;
}
else if (hrs == S_OK)
{
outfile << "\n MAPI log in successful.";
return SUCCESS_SUCCESS;
}
outfile << "\n Last Error - " << GetLastError();
}
return MAPI_E_FAILURE;
}
这里,我可以成功初始化MAPI,但是MAPILogOnEx(...)返回null,那么这里还有什么需要的吗?
GetLastError() 给出 0。“Outlook”是默认配置文件。
我看过stackoverflow和微软的所有教程,但没有找到解决办法。
【问题讨论】:
标签: c++ mapi office-2007 windows-messages