我的应用程序无法使用 MAPI 子系统正确创建 MAPI/消息传递配置文件
我有一个创建 MAPI 配置文件来发送邮件/消息的应用程序。在 Outlook2007 环境中正确创建配置文件,但在 Outlook2007 SP2 环境中未正确创建配置文件。源代码和“MAPI/outlook 配置文件的交换环境”相同。配置文件是使用 MAPI 子系统创建的。
关于应用程序的描述: 该应用程序是一个基于Windows 服务的应用程序。该服务执行 COM 应用程序。 COM 应用程序生成一个新线程来创建新配置文件并发送示例消息。
实际问题:在配置文件创建期间,对ConfigureMsgService 函数(属于IMsgServiceAdmin)的调用即使返回S_OK 也无法正常工作。下面给出了ConfigureMsgService 函数的第5 个参数“lpProps”的值。
// First, the mailbox name.
ZeroMemory(&rgval[0], sizeof(SPropValue) );
rgval[0].ulPropTag = PR_PROFILE_UNRESOLVED_NAME;
rgval[0].Value.lpszA = szMailbox;
// Next, the server name.
ZeroMemory(&rgval[1], sizeof(SPropValue) );
rgval[1].ulPropTag = PR_PROFILE_UNRESOLVED_SERVER;
rgval[1].Value.lpszA = szServer;
// For NT Services, need to do this to keep MAPI from
// displaying dialog boxes.
ZeroMemory(&rgval[2], sizeof(SPropValue) );
rgval[2].ulPropTag = PR_CONVERSION_PROHIBITED; //As the com application is executed by the NT service, this parameter is specified.
rgval[2].Value.b = TRUE;
另请注意,在调用ConfigureMsgService 函数之前,所有其他MAPI 调用(例如MAPIInitialize、MAPIAdminProfiles、CreateProfile、AdminServices、CreateMsgService、GetMsgServiceTable 等)都会成功。
我的问题是,相同的代码在 Outlook 2007 环境中可以正常工作,但在 Outlook 2007 SP2 环境中却失败了。
请注意, 1.当从独立应用程序执行相同的代码时,它工作得很好。 2. 如果服务作为本地系统帐户或网络服务帐户执行,则代码无法正常工作。
- 可能是什么问题?我是不是错过了什么?
- 有没有可用的解决方法?
提前致谢 沙拉瓦南
I have an application which creates a MAPI profile to send mails/messages. The profile is getting created properly on Outlook2007 environment, but it is not getting created properly on Outlook2007 SP2 environment. Both the source code and "exchange environment to which MAPI/outlook profile" are same. The profile is created using MAPI subsystem.
Description about the application: The application is a windows service-based application. The service executes a COM application. The COM application spawns a new thread to create a new profile and sends a sample message.
Actual problem: During the profile creation, the call to the ConfigureMsgService function (that belongs to IMsgServiceAdmin) is not working properly even though it returns S_OK. The value for the 5th parameter "lpProps" of ConfigureMsgService function is given below.
// First, the mailbox name.
ZeroMemory(&rgval[0], sizeof(SPropValue) );
rgval[0].ulPropTag = PR_PROFILE_UNRESOLVED_NAME;
rgval[0].Value.lpszA = szMailbox;
// Next, the server name.
ZeroMemory(&rgval[1], sizeof(SPropValue) );
rgval[1].ulPropTag = PR_PROFILE_UNRESOLVED_SERVER;
rgval[1].Value.lpszA = szServer;
// For NT Services, need to do this to keep MAPI from
// displaying dialog boxes.
ZeroMemory(&rgval[2], sizeof(SPropValue) );
rgval[2].ulPropTag = PR_CONVERSION_PROHIBITED; //As the com application is executed by the NT service, this parameter is specified.
rgval[2].Value.b = TRUE;
Also note, prior to ConfigureMsgService function call, all the other MAPI calls such as MAPIInitialize, MAPIAdminProfiles, CreateProfile, AdminServices, CreateMsgService, GetMsgServiceTable etc are succeeded.
My question, the same code was working properly with Outlook 2007 environment, but it failed in Outlook 2007 SP2 environment.
Please note,
1. when the same code is executed from a stand-alone application, it worked fine.
2. The code didn't work properly if the service is executed as a Local System account or as a network service account.
- What could be the problem? Am I missing some thing.
- Is there any work-around is available?
Thanks in advance
Saravanan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的问题在你的笔记的#2中:
MAPI 配置文件存储在注册表中当前用户的配置单元*(HKEY_CURRENT_USER 和 HKEY_USERS{user SID})中。系统帐户(LocalSystem 和 NetworkService)不提供 MAPI 需要写入配置文件信息的用户配置单元。
最简单的解决方法是让您的服务在已被授予“作为服务登录”权限的用户帐户下运行。根据 COM 应用程序的运行方式(进程内还是进程外),您也许可以将其作为特定用户而不是系统帐户运行。
*Hive 是用于注册表不同部分的术语。这里我们只处理用户自己的注册表部分。
Your problem is in #2 of your note:
MAPI profiles are stored in the current user's hive* in the registry (HKEY_CURRENT_USER and HKEY_USERS{user SID}). The system accounts (LocalSystem and NetworkService) don't present a user hive which MAPI needs to write the profile information.
The easiest fix is to have your service run under a user account which has been granted the Log On As Service right. Depending on how your COM app is run as (in proc vs out of proc) you may be able to have it run as a specific user instead of a system account.
*Hive is the term used for the different sections of the registry. Here we're just dealing with the user's own section of the registry.
感谢您的回复。
我尝试了你的想法,但没有成功。在这种情况下,我与微软进行了交谈,他们已经提供了针对此问题的修复程序(http://support.microsoft.com/kb/972363),它修复了它。
沙拉瓦南
Thanks for your reply.
I tried your idea, but it doesn't worked. I spoke to Microsoft in this case, they have provided a fix for this issue(http://support.microsoft.com/kb/972363), it fixed it.
Saravanan