在未安装 Outlook 的情况下创建 MAPI 配置文件
2011-02-24 21:33
253 查看
人们通常认为,Exchange Server 上必须安装 MAPI 客户端(例如 Microsoft Outlook 或 Exchange 客户端)才能创建 MAPI 配置文件;这种想法是错误的。因为此原因而安装 MAPI 客户端是不必要的,而且就 Outlook 而言,不建议您在生产服务器上安装它。只要安装有 MAPI 子系统(Exchange 中已经包含此子系统),就可以通过其他各种方法来创建 MAPI 配置文件。
您尝试其中任一种方法之前,您需要确保服务器上的 Mapisvc.inf 文件中生成了适当的项目。 有关如何修改该文件的其他信息,请单击下面的文章编号,以查看 Microsoft 知识库中相应的文章:
294470 (http://support.microsoft.com/kb/294470/EN-US/ ) HOWTO:Add Entries For Exchange Services to Mapisvc.inf
// ]]>
此实用工具随 Microsoft Outlook 一起提供。您可以在 MSDN Library 中的“Creating a Profile with NEWPROF”(使用 NEWPROF 创建配置文件)主题下找到它的使用说明。 有关其他信息,请单击下面的文章编号,以查看 Microsoft 知识库中相应的文章:
145905 (http://support.microsoft.com/kb/145905/EN-US/ ) XCLN:Newprof.exe Command-Line Options
148664 (http://support.microsoft.com/kb/148664/EN-US/ ) XCLN:Description of the Profile Descriptor File
// ]]>
该示例使用 MAPI IProfAdmin 接口(参见下面的方法 5 中的说明)。您可以在以下文章中找到此示例:
228736 (http://support.microsoft.com/kb/228736/EN-US/ ) 示例:Profman2.exe - MAPI 配置文件管理器 v2.0
// ]]>
当调用 MAPILogonEx 而没有指定配置文件并且设置了 MAPI_LOGON_UI 标志时,如果计算机上没有任何配置文件,MAPI 会显示配置文件创建向导。如果有现有的配置文件,MAPI 则显示选择配置文件对话框。单击新建以启动配置文件创建向导。
示例代码
[/code]
// ]]>
该函数直接调用配置文件创建向导。
示例代码
[/code]
// ]]>
使用此 MAPI 接口,您可以在无用户干预的情况下以编程方式创建配置文件。
示例代码
[/code]
示例
// loadTOCNode(2, 'moreinformation');
// ]]>
从 Microsoft 下载中心可以下载以下文件:
Profiler.exe (http://download.microsoft.com/download/exchplatinumbeta/sample/1.0/nt45/en-us/profiler.exe)
Profiler.exe 是一个简单的 Microsoft Visual C++ 示例,它演示了上面的方法 3 到方法 5。Profiler.exe 文件包含下列文件:
您尝试其中任一种方法之前,您需要确保服务器上的 Mapisvc.inf 文件中生成了适当的项目。 有关如何修改该文件的其他信息,请单击下面的文章编号,以查看 Microsoft 知识库中相应的文章:
294470 (http://support.microsoft.com/kb/294470/EN-US/ ) HOWTO:Add Entries For Exchange Services to Mapisvc.inf
1. 使用 NewProf.exe
// loadTOCNode(3, 'moreinformation');// ]]>
此实用工具随 Microsoft Outlook 一起提供。您可以在 MSDN Library 中的“Creating a Profile with NEWPROF”(使用 NEWPROF 创建配置文件)主题下找到它的使用说明。 有关其他信息,请单击下面的文章编号,以查看 Microsoft 知识库中相应的文章:
145905 (http://support.microsoft.com/kb/145905/EN-US/ ) XCLN:Newprof.exe Command-Line Options
148664 (http://support.microsoft.com/kb/148664/EN-US/ ) XCLN:Description of the Profile Descriptor File
2. 使用 ProfMan2 示例
// loadTOCNode(3, 'moreinformation');// ]]>
该示例使用 MAPI IProfAdmin 接口(参见下面的方法 5 中的说明)。您可以在以下文章中找到此示例:
228736 (http://support.microsoft.com/kb/228736/EN-US/ ) 示例:Profman2.exe - MAPI 配置文件管理器 v2.0
3. 使用 MAPILogonEx
// loadTOCNode(3, 'moreinformation');// ]]>
当调用 MAPILogonEx 而没有指定配置文件并且设置了 MAPI_LOGON_UI 标志时,如果计算机上没有任何配置文件,MAPI 会显示配置文件创建向导。如果有现有的配置文件,MAPI 则显示选择配置文件对话框。单击新建以启动配置文件创建向导。
示例代码
[code]// CreateProfileWithMAPILogonEx function: This takes advantage of the // profile prompt dialog's "New" button. bool CreateProfileWithMAPILogonEx() { HRESULT hRes = S_OK; // Return code from MAPI calls. LPMAPISESSION lpSession = NULL; // MAPI Session pointer. // Initialize MAPI. if (FAILED(hRes = MAPIInitialize(NULL))) { cout<<"Error initializing MAPI. hRes = 0x"<<hex<<hRes<<dec<<endl; return FALSE; } // Instruct user to click the "New" button. cout<<"When the \"Choose Profile\" dialog appears, click the \"New\" button" <<"to configure a new profile."<<endl; // Call MAPILogonEx to display the profile chooser dialog. if (FAILED(hRes = MAPILogonEx(NULL, NULL, NULL, MAPI_LOGON_UI, &lpSession))) { cout<<"Error logging on. hRes = 0x"<<hex<<hRes<<dec<<endl; return FALSE; } // Log off the session. if (FAILED(hRes = lpSession->Logoff(0,0,0))) { cout<<"Error logging off. hRes = 0x"<<hex<<hRes<<dec<<endl; } // Release the session. lpSession->Release(); // Uninitialize MAPI. MAPIUninitialize(); // Return true to indicate success. return TRUE; }
[/code]
4. 使用 LAUNCHWIZARDENTRY 函数
// loadTOCNode(3, 'moreinformation');// ]]>
该函数直接调用配置文件创建向导。
示例代码
[code]// CreateProfileWithLAUNCHWIZARD function: This uses the LAUNCHWIZARDENTRY API // to display the profile configuration UI. bool CreateProfileWithLAUNCHWIZARD() { HRESULT hRes = S_OK; // Return code from MAPI calls. TCHAR szProfName[80] = {0}; // String to hold profile name. LPTSTR szServices[] = {"MSEMS", NULL}; // String to hold message service names. // Call LaunchWizard to add the MSEMS service. if (FAILED(hRes = LaunchWizard(NULL, NULL, (LPCTSTR *)szServices, 80, szProfName))) { cout<<"Error launching wizard. hRes = 0x"<<hex<<hRes<<dec<<endl; return FALSE; } // Return true indicating success. return TRUE; }
[/code]
5. 使用 MAPI IProfAdmin 接口
// loadTOCNode(3, 'moreinformation');// ]]>
使用此 MAPI 接口,您可以在无用户干预的情况下以编程方式创建配置文件。
示例代码
[code]// CreateProfileWithIProfAdmin function: This uses the MAPI IProfAdmin to // programmatically create a profile. No UI is displayed. bool CreateProfileWithIProfAdmin() { HRESULT hRes = S_OK; // Result from MAPI calls. LPPROFADMIN lpProfAdmin = NULL; // Profile Admin object. LPSERVICEADMIN lpSvcAdmin = NULL; // Service Admin object. LPMAPITABLE lpMsgSvcTable = NULL; // Table to hold services. LPSRowSet lpSvcRows = NULL; // Rowset to hold results of table query. SPropValue rgval[2]; // Property structure to hold values we want to set. SRestriction sres; // Restriction structure. SPropValue SvcProps; // Property structure for restriction. char szProfile[80] = {0}; // String for profile name. char szMailbox[80] = {0}; // String for mailbox name. char szServer[80] = {0}; // String for server name. // This indicates columns we want returned from HrQueryAllRows. enum {iSvcName, iSvcUID, cptaSvc}; SizedSPropTagArray(cptaSvc,sptCols) = { cptaSvc, PR_SERVICE_NAME, PR_SERVICE_UID }; // Get configuration info from user. cout<<"Enter name for profile: "; cin>>szProfile; cout<<"Enter Exchange mailbox name: "; cin>>szMailbox; cout<<"Enter Exchange server name: "; cin>>szServer; // Initialize MAPI. if (FAILED(hRes = MAPIInitialize(NULL))) { cout<<"Error initializing MAPI."; goto error; } // Get an IProfAdmin interface. if (FAILED(hRes = MAPIAdminProfiles(0, // Flags. &lpProfAdmin))) // Pointer to new IProfAdmin. { cout<<"Error getting IProfAdmin interface."; goto error; } // Create a new profile. if (FAILED(hRes = lpProfAdmin->CreateProfile(szProfile, // Name of new profile. NULL, // Password for profile. NULL, // Handle to parent window. NULL))) // Flags. { cout<<"Error creating profile."; goto error; } // Get an IMsgServiceAdmin interface off of the IProfAdmin interface. if (FAILED(hRes = lpProfAdmin->AdminServices(szProfile, // Profile that we want to modify. NULL, // Password for that profile. NULL, // Handle to parent window. 0, // Flags. &lpSvcAdmin))) // Pointer to new IMsgServiceAdmin. { cout<<"Error getting IMsgServiceAdmin interface."; goto error; } // Create the new message service for Exchange. if (FAILED(hRes = lpSvcAdmin->CreateMsgService("MSEMS", // Name of service from MAPISVC.INF. NULL, // Display name of service. NULL, // Handle to parent window. NULL))) // Flags. { cout<<"Error creating Exchange message service."; goto error; } // We now need to get the entry id for the new service. // This can be done by getting the message service table // and getting the entry that corresponds to the new service. if (FAILED(hRes = lpSvcAdmin->GetMsgServiceTable(0, // Flags. &lpMsgSvcTable))) // Pointer to table. { cout<<"Error getting Message Service Table."; goto error; } // Set up restriction to query table. sres.rt = RES_CONTENT; sres.res.resContent.ulFuzzyLevel = FL_FULLSTRING; sres.res.resContent.ulPropTag = PR_SERVICE_NAME; sres.res.resContent.lpProp = &SvcProps; SvcProps.ulPropTag = PR_SERVICE_NAME; SvcProps.Value.lpszA = "MSEMS"; // Query the table to get the entry for the newly created message service. if (FAILED(hRes = HrQueryAllRows(lpMsgSvcTable, (LPSPropTagArray)&sptCols, &sres, NULL, 0, &lpSvcRows))) { cout<<"Error querying table for new message service."; goto error; } // Setup a SPropValue array for the properties you need to configure. // First, the server name. ZeroMemory(&rgval[1], sizeof(SPropValue) ); rgval[1].ulPropTag = PR_PROFILE_UNRESOLVED_SERVER; rgval[1].Value.lpszA = szServer; // Next, the mailbox name. ZeroMemory(&rgval[0], sizeof(SPropValue) ); rgval[0].ulPropTag = PR_PROFILE_UNRESOLVED_NAME; rgval[0].Value.lpszA = szMailbox; // Configure the message service with the above properties. if (FAILED(hRes = lpSvcAdmin->ConfigureMsgService( (LPMAPIUID)lpSvcRows->aRow->lpProps[iSvcUID].Value.bin.lpb, // Entry ID of service to configure. NULL, // Handle to parent window. 0, // Flags. 2, // Number of properties we are setting. rgval))) // Pointer to SPropValue array. { cout<<"Error configuring message service."; goto error; } goto cleanup; error: cout<<" hRes = 0x"<<hex<<hRes<<dec<<endl; return FALSE; cleanup: // Clean up. if (lpSvcRows) FreeProws(lpSvcRows); if (lpMsgSvcTable) lpMsgSvcTable->Release(); if (lpSvcAdmin) lpSvcAdmin->Release(); if (lpProfAdmin) lpProfAdmin->Release(); MAPIUninitialize(); return TRUE; }
[/code]
示例
// loadTOCNode(2, 'moreinformation');
// ]]>
从 Microsoft 下载中心可以下载以下文件:
Profiler.exe (http://download.microsoft.com/download/exchplatinumbeta/sample/1.0/nt45/en-us/profiler.exe)
Profiler.exe 是一个简单的 Microsoft Visual C++ 示例,它演示了上面的方法 3 到方法 5。Profiler.exe 文件包含下列文件:
文件名 | 大小 |
---|---|
Profiler.dsw | 1 KB |
Profiler.dsp | 5 KB |
Profiler.cpp | 12 KB |
相关文章推荐
- maven的安装、路径配置、修改库文件路径和eclipse中的配置、创建maven工程。
- 安装与配置-以前的某个程序安装已在安装计算机上创建挂起的文件操作......
- maven的安装、路径配置、修改库文件路径和eclipse中的配置、创建maven工程。
- hibernate的环境搭建和安装插件和创建配置文件
- windows下pycharm安装、创建文件、配置默认模板
- maven的安装、路径配置、修改库文件路径和eclipse中的配置、创建maven工程。
- Git学习笔记(1)——安装,配置,创建库,文件添加到库
- 安装oralce 11g后创建监听失败,缺失监听配置文件,也无法生成,提示TNS-04415
- Maven安装与配置SpringToolSuite创建项目时的配置以及pomXml和spring_beansXml以及日志文件
- 有关oracle遇到日期显示问题,导入导出,安装,卸载,修改listener配置文件,创建用户和表空间等的部分问题.
- OCM_第十七天课程:Section7 —》GI 及 ASM 安装配置 _管理和配置 GRID /实施 ASM 故障组 /创建 ACFS 文件系统
- 创建Ubuntu samba配置文件安装
- Mac安装MySQL、修改MySQL的初始化密码、默认字符集为utf-8以及配置完my.cnf的文件后仍不生效的情况下的处理方案
- windows 安装pycharm 、创建文件、配置默认模板
- wordpress安装,创建配置文件无反应
- 安装oralce11g后创建监听失败,缺失监听配置文件,也无法生成,提示TNS-04415
- 利用NSIS创建程序安装文件
- ubuntu12.04 amd64 安装 samba和配置VMWARE共享文件
- 双击运行Android模拟器、创建SDcard、AVD、安装APK文件、上传文件到模拟器
- 文件备份,同步工具rsync服务器端的安装及配置