简体   繁体   English

如何使用MAPI从配置文件中获取电子邮件地址

[英]How to get email address from profile with MAPI

I'm using MapiEx(http://www.codeproject.com/Articles/10881/MAPIEx-Extended-MAPI-Wrapper) to generate a mail. 我正在使用MapiEx(http://www.codeproject.com/Articles/10881/MAPIEx-Extended-MAPI-Wrapper)生成邮件。

I need the name and e-mail logged in the MAPI client to set as the sender in the e-mail. 我需要在MAPI客户端中记录的名称和电子邮件,以设置为电子邮件中的发件人。

The class CMAPIEx has the methods GetProfileName and GetProfileEmail, but to use those methods, I need to log in the MAPI with the user profile. CMAPIEx类具有GetProfileName和GetProfileEmail方法,但是要使用这些方法,我需要使用用户配置文件登录MAPI。

In the Login method of CMAPIEx I can pass the ProfileName, but I don't know what to pass. 在CMAPIEx的Login方法中,我可以传递ProfileName,但我不知道要传递什么。

My MAPI client is Outlook 2010, I tried to pass the e-mail or name that I set in my account, but nothing worked. 我的MAPI客户端是Outlook 2010,我试图传递我在帐户中设置的电子邮件或名称,但没有任何效果。

I looked the Login method in the CMAPIEx class and I found this: 我查看了CMAPIEx类中的Login方法,我发现了这个:

DWORD dwFlags=MAPI_EXTENDED | MAPI_USE_DEFAULT | MAPI_NEW_SESSION;
if(bInitAsService) dwFlags|=MAPI_EXPLICIT_PROFILE | MAPI_NT_SERVICE;
return (MAPILogonEx(NULL, (LPTSTR)szProfileName, NULL, dwFlags, &m_pSession)==S_OK);

The third parameter of MAPILogonEx is the password and my account in Outlook has a password but in MAPILogonEx documentation(http://msdn.microsoft.com/en-us/library/office/cc815545.aspx) is said to let the password as NULL. MAPILogonEx的第三个参数是密码,我在Outlook中的帐户有密码,但在MAPILogonEx文档(http://msdn.microsoft.com/en-us/library/office/cc815545.aspx)中说密码为空值。

As I said in the second paragraph, I only need the name and e-mail logged in the MAPI client, if somebody knows what I'm doing wrong or some other way to get those information, please tell me. 正如我在第二段中所说,我只需要在MAPI客户端中记录的名称和电子邮件,如果有人知道我做错了什么或其他方式来获取这些信息,请告诉我。

Sorry for the bad english. 抱歉英语不好。

If you do not pass the profile name, you will end up with the default profile. 如果您未传递配置文件名称,则最终将使用默认配置文件。 You can see the names of the existing profiles in Control Panel | 您可以在“控制面板”中查看现有配置文件的名称 Mail | 邮件| Show Profiles. 显示个人资料。 To enumarate the existing profiles programmatically, use IProfAdmin::GetProfileTable() 要以编程方式创建现有配置文件,请使用IProfAdmin :: GetProfileTable()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM