Exchange 的 Logon 问题

frogdan 2003-02-10 08:52:41
我想由用户直接提供 Exchange Server 名或 IP,还有 Exchange 上的 Username,Password,用于 VB 上 CDO Session 的登录,而不用本机的 Profile。请问应如何实现?谢谢!
...全文
26 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
13161795500 2003-02-12
  • 打赏
  • 举报
回复
up
Introduction During the software development, I have seen many applications that requires incorporating email support. I remember, once I was to develop an application, which sends emails at the specific time to specific people with the customized messages. For that I developed a COM service that used MAPI. MAPI, i.e. Messaging Application Programming Interface, is the standard messaging architecture and a complete set of functions and object-oriented interfaces. Here I have an Email component, a COM DLL, which is a set of messaging functions that helps you create messaging-enabled applications. This COM component uses Simple MAPI to achieve that. Note: MAPI is used by various industry-standard e-mail clients, such as the Microsoft Exchange client, all versions of Microsoft Outlook and Outlook Express, including QUALCOMM Incorporated (Eudora) and Netscape Communications Corporation. So you can use this component with these client applications also. Component Design The CLSID of the Email component is CLSID_Mail and it has only one interface IMail with the interface ID IID_IMail. CMail is the implementation class and contains following data members: m_MAPILogon Function pointer for MAPILogon m_MAPISendMail Function pointer for MAPISendMail m_MAPISendDocuments Function pointer for MAPISendDocuments m_MAPIFindNext Function pointer for MAPIFindNext m_MAPIReadMail Function pointer for MAPIReadMail m_MAPIResolveName Function pointer for MAPIResolveName m_MAPIAddress Function pointer for MAPIAddress m_MAPILogoff Function pointer for MAPILogoff m_MAPIFreeBuffer Function pointer for MAPIFreeBuffer m_MAPIDetails Function pointer for MAPIDetails m_MAPISaveMail Function pointer for MAPISaveMail IMail have the following functions: IsMapiInstalled Checks if the MAPI is installed on the system. It searches Win.INI file for the MAPI key. If found it returns S_OK. InitMapi After checking the through IsMapiInstalled, it initializes the MAPI function pointers. Method should be called once before using the component. put_strProfileName Takes the name of the outlook profile name you are using to send the email. put_strEmailAddress Sets the recipient email address. You can specify more than one comma (,) separated recipient addresses. put_strRecipient Sets the name you want to specify for the recipients, sets the email names of the sender – it may be different from your specified profile email address. put_strSubject Sets the subject of the email. get_strSubject Returns the email subject. put_strMessage Sets email message text. get_strMessage Returns message text. put_strAttachmentFilePath Sets the email attachment with the full path like “c:\abc.txt”. get_strAttachmentFilePath Returns the path of email attachment. put_strAttachmentFile The display name of the attachment (Sample.txt), by default, it’s the same as that specified in put_strAttachmentFilePath. get_strAttachmentFile Returns the attachment file name. Logon Opens a new logon session if not already opened, using specified outlook profile, name and the profile password, you must logon before sending the email. I have set password to NULL assuming that the profile you will specify have NO password, but you can specify your own password. Automatically called by Send method. Logoff Logs off, and closes the session. Automatically called by Send method after sending the email. Send Sends the email, requires valid outlook profile name, recipient email address and a login session to send email. Steps to execute the demo project The demo project demonstrates the way you can use the component to send an email. In order to execute the demo project, the following settings are required: Step 1: You must have some valid Output Express email account or create one named TestProfile. You can create an email profile in Express from Tools>Accounts menu. This will open Internet Accounts property sheet. On the tab All, click the button Add and then Mail. A wizard will let you create an email account, specify the valid email address. For hotmail account, wizard automatically sets the names of email servers. After successfully creating the account, select the account name from the list in All tab (for hotmail account, the default account name is Hotmail). Open account properties by pressing Properties button and change the account name from default name (say Hotmail) to TestProfile. Step 2: Register the DLL All COM DLLs required to be registered. After copying the DLL source code, you can register the DLL by right clicking the DLL and selecting Register DLL or Register COM component option, or simply by double clicking the DLL. Compiling the DLL code in Visual Studio will automatically register the DLL. Step 3: Logged on to the net Make sure you are logged on to the net. If not, outlook will fail to deliver the email, however, you can still check the composed email in your outbox. How to send email? After specifying the information in the dialog box, click the Send button. A warning message will be displayed, click Send button. Note:The warning dialog is displayed because of the security constraints. If you want to get rid of this dialog box, then you will have to use Extended MAPI instead of simple MAPI. Here is the method CTestEmailDlg::OnSend method, which is used to pass the user specified information to the email object and call the IMail::Send method after setting everything. Collapse | Copy Code //##//##////////////////////////////////////////////////////////////// /////////////////////////////////////////////// // // void CTestEmailDlg::OnSend() // // This module is called when send button is pressed and uses //Email COM DLL to send email - Aisha Ikram // Note: dont forget to initialize COM library using CoInitialize(NULL); //##//##//////////////////////////////////////////////////////////////////// /////////////////////////////////////////////// void CTestEmailDlg::OnSend() { UpdateData(); try{ CComPtr objMail; HRESULT hr; // make sure the DLL is registered hr = objMail.CoCreateInstance(CLSID_Mail); if(SUCCEEDED(hr)) { if(hr== S_OK) { // profile name is compulsory, this is the outlook profile, // i used "outlook express" as configuring it is easier than // "MS outlook" make sure to specify the correct sender's address // for this profile and make sure that outlook express is //the default email client. if(m_strProfile.IsEmpty()) { AfxMessageBox("Please specify email profile name "); return; } if(m_strTo.IsEmpty()) { AfxMessageBox("Please specify recipient's email address "); return; } // by default, it's TestProfile, assumes that a profile with this //name exists in outlook hr= objMail->put_strProfileName((_bstr_t)m_strProfile); hr = objMail->put_strSubject((_bstr_t)m_strSubject); // this is the email or set of email addresses (separated by ,) // which is actually used to send email hr = objMail->put_strEmailAddress((_bstr_t)m_strTo); // recipient is just to show the display name hr = objMail->put_strRecipient((_bstr_t)m_strTo); hr = objMail->put_strAttachmentFilePath((_bstr_t)m_strAttachment); hr = objMail->put_strMessage((_bstr_t)m_strMessage); hr= objMail->Send(); if(hr!=S_OK) AfxMessageBox("Error, make sure the info is correct"); }//if } //if } // try catch(...) { AfxMessageBox("Error, make sure specified info is correct"); } } Check the mail in the recipient inbox. Where to use This component can be extended to incorporate the functionalities like opening an existing inbox to read emails automatically from the inbox and composing new emails etc. It can be used to send emails automatically with customized user messages and attachments to specific people at particular time, especially while using some exe servers or NT services. That's it. If there is any suggestions or comments you are most welcome. Your rating would help me evaluate the standard of my article.
理解Microsoft专家认证程序 理解Microsoft认证的不同等级和类型 选择成为MCP(Microsft认证专家)的考试科目 选择成为MCSD的考试科目 选择成为MCT的考试科目 MCSE认证考试的科目 选择合适的MCSE课程组合 核心课程考试 选修课程考试 考试编号的识别 课程内容和考试内容的对照 理解微软的MCSE长远考虑 理解微软出题的方式 使用本书帮助备考 在Internet上寻找对考试有帮助的信息 寻求微软认可的课程指导 寻找高质量的和三方帮助 寻找可利用的评估软件拷贝 报名参加考试 考试的费用问题 考前的自我调整 使用考试中心提供的考试工具 参加模拟测试 熟悉使用计算机进行考试 充分利用考试时间 考题的形式 理解多重选择题型 理解对错题题型 理解多重选择多重答案题型 理解基于解决方案型的问题 理解“建议方法”类型的考题 分析考试结果 准备重新考试 合理安排考试课程的顺序 熟悉Windows系列产品 比较Windows NT Server和NT Workstation 比较Windows NT Workstaton和Windows 95 在Windowx 95和Windows NT Workstation之间作出选择 关于Microsoft Windows NT的70-069号考试:实现和支持Microsoft Windows NT Server 4.0 70-069号考试(实现和支持Microsoft Windows NT Server 4.0)覆盖的内容 Windows NT 4.0界面简介 Windows NT 4.0任务栏(taskbar)的使用 Windows NT回收站简介 Windows NT帐号简介 理解单域模型支持和帐号数量 安全认证号简介 使用管理向导(Administrative Wizards)创建帐号 使用Server Manager(服务器管理器)程序创建计算机帐号 Userver Manager for Domains(域的用户管理器)简介 使用User Mnager for Domains创建用户帐号 刷新用户帐号列表 用户帐号列表的排序 事件查看器(Event View)程序简介 筛选Event Viewer中的事件 授予用户在本地登录的权利 使用Windows NT诊断程序查看系统配置 激活“Windows NT Security(Windows NT安全)”对话框 理解登录验证过程 理解访问令牌(Access Token) Windows NT目录服务简介 理解Windows NT如何构造用户帐号数据库 使用Windows NT中的Ctrl+Alt+Del组合键 把Windows NT计算机设置成自动登录 改变Windows NT口令 用拨号网络登录 复制用户帐号 为简化多个帐号的创建工作而建立用户帐号模板 删除和重新命名用户帐号 理解保护缺省的Administrator帐号的重要性 重新命名管理员帐号 理解缺省的Guest帐户 Windows NT在哪里创建帐号 设置口令限制条件 设置用户登录地点 创建宿主文件夹 设置用户登录时间 创建临时用户帐号 重新设置用户帐号口令 修改多个用户帐号 自动注销有时间限制的用户 要求用户在下次登录时改变口令 设置帐号规则 设置用户口令永不过期 停用用户帐号 解开登录失败后的用户帐号 Windows NT组简介 理解用户权限和组的访问权限 理解用户和组的权利 分清权限(permission)和权利(right) 设置组成成员关系 理解全局帐号 理解本地帐号 定义Everyone组 Network组的详细说明 Inteactive组的详细说明 Administrators组的详细说明 Guest组的详细说明 Users组的详细说明 Print Operators组的详细说明 Backup Operators(帐户操作员)组的详细说明 Replicator(复制员)组的详细说明 Domain Guests(域客户)组的详细说明 Domain Users(域用户)组的详细说明 Domain Admins(域管理员)组的详细说明 赋予拨号进入权限 理解用户配置文件(User Profile) 为Windows用户创建并使用登录脚本文件(Logon Script) 创建漫游式用户配置文件(Roaming User Profile) 创建强制性用户配置文件(Mandatory User Profile) 为用户帐号分配一个配置文件 创建帐户时变量的使用 创建随机初始化口令 理解内建组(Built-in Group) 理解组和策略 设置主组(Primary Group) 理解删除一个组的影响 域控制器(Domain Controller)简介 成员服
网管教程 从入门到精通软件篇 ★一。★详细的xp修复控制台命令和用法!!! 放入xp(2000)的光盘,安装时候选R,修复! Windows XP(包括 Windows 2000)的控制台命令是在系统出现一些意外情况下的一种非常有效的诊断和测试以及恢复系统功能的工具。小编的确一直都想把这方面的命令做个总结,这次辛苦老范给我们整理了这份实用的秘笈。   Bootcfg   bootcfg 命令启动配置和故障恢复(对于大多数计算机,即 boot.ini 文件)。   含有下列参数的 bootcfg 命令仅在使用故障恢复控制台时才可用。可在命令提示符下使用带有不同参数的 bootcfg 命令。   用法:   bootcfg /default  设置默认引导项。   bootcfg /add    向引导列表中添加 Windows 安装。   bootcfg /rebuild  重复全部 Windows 安装过程并允许用户选择要添加的内容。   注意:使用 bootcfg /rebuild 之前,应先通过 bootcfg /copy 命令备份 boot.ini 文件。   bootcfg /scan    扫描用于 Windows 安装的所有磁盘并显示结果。   注意:这些结果被静态存储,并用于本次会话。如果在本次会话期间磁盘配置发生变化,为获得更新的扫描,必须先重新启动计算机,然后再次扫描磁盘。   bootcfg /list   列出引导列表中已有的条目。   bootcfg /disableredirect 在启动引导程序中禁用重定向。   bootcfg /redirect [ PortBaudRrate] |[ useBiosSettings]   在启动引导程序中通过指定配置启用重定向。   范例: bootcfg /redirect com1 115200 bootcfg /redirect useBiosSettings   hkdsk   创建并显示磁盘的状态报告。Chkdsk 命令还可列出并纠正磁盘上的错误。   含有下列参数的 chkdsk 命令仅在使用故障恢复控制台时才可用。可在命令提示符下使用带有不同参数的 chkdsk 命令。   vol [drive:] [ chkdsk [drive:] [/p] [/r]   参数  无   如果不带任何参数,chkdsk 将显示当前驱动器中的磁盘状态。 drive: 指定要 chkdsk 检查的驱动器。 /p   即使驱动器不在 chkdsk 的检查范围内,也执行彻底检查。该参数不对驱动器做任何更改。 /r   找到坏扇区并恢复可读取的信息。隐含着 /p 参数。   注意 Chkdsk 命令需要 Autochk.exe 文件。如果不能在启动目录(默认为 %systemroot%System32)中找到该文件,将试着在 Windows 安装 CD 中找到它。如果有多引导系统的计算机,必须保证是在包含 Windows 的驱动器上使用该命令。 Diskpart   创建和删除硬盘驱动器上的分区。diskpart 命令仅在使用故障恢复控制台时才可用。   diskpart [ /add |/delete] [device_name |drive_name |partition_name] [size]   参数 无   如果不带任何参数,diskpart 命令将启动 diskpart 的 Windows 字符模式版本。   /add   创建新的分区。   /delete   删除现有分区。   device_name   要创建或删除分区的设备。设备名称可从 map 命令的输出获得。例如,设备名称:   DeviceHardDisk0   drive_name   以驱动器号表示的待删除分区。仅与 /delete 同时使用。以下是驱动器名称的范例:   D:   partition_name   以分区名称表示的待删除分区。可代替 drive_name 使用。仅与 /delete 同时使用。以下是分区名称的范例:   DeviceHardDisk0Partition1    大小   要创建的分区大小,以兆字节 (MB)表示。仅与 /add 同时使用。   范例   下例将删除分区: diskpart /delete Device HardDisk0 Partition3 diskpart /delete F:   下例将在硬盘上添加一个 20 MB 的分区:   diskpart /add Device HardDisk0 20   Fixboot

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧