以编程方式获取Outlook收件箱 [英] getting at outlook inboxes programmatically

查看:92
本文介绍了以编程方式获取Outlook收件箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以编程方式访问不同的用户收件箱(请参阅下面的代码

)。它工作正常,除了登录行似乎总是登录到我的本地帐户而不是登录到网络上的其他

帐户。有人知道如何使用这种方法登录其他人的

帐户吗?


//创建Outlook应用程序

Outlook .Application oApp = new Outlook.Application();


//获取MAPI命名空间

Outlook.NameSpace oNS = oApp.GetNamespace(" mapi") ;


oNS.Logon(" user"," password",false,true);


//获取消息集合收件箱

Outlook.MAPIFolder oInbox =

oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderInbox);


Outlook.Items oItems = oInbox.Items;


int intTotalNumberOfItemsInInbox = oItems.Count;


//获取未读电子邮件

oItems = oItems.Restrict(" [Unread] = true");

int intTotalUnread = oItems.Count;



* **通过开发人员指南 http://www.developersdex.com 发送***

I am trying to get at different users inboxes programmatically (see code
below). It works fine, except for the fact that the logon line seems to
always logon to my local account rather than logging on to other
accounts on the network. Anybody know how to logon to other people''s
accounts using this method?

//Create Outlook application
Outlook.Application oApp = new Outlook.Application();

//Get MAPI namespace
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

oNS.Logon("user", "password", false, true);

//Get Messages collection of Inbox
Outlook.MAPIFolder oInbox =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderInbox);

Outlook.Items oItems = oInbox.Items;

int intTotalNumberOfItemsInInbox = oItems.Count;

//Get unread e-mail messages
oItems = oItems.Restrict("[Unread] = true");
int intTotalUnread = oItems.Count;


*** Sent via Developersdex http://www.developersdex.com ***

推荐答案

2月19日上午10:58,Mike P< mike.p ... @ gmail.comwrote:
On Feb 19, 10:58 am, Mike P <mike.p...@gmail.comwrote:

我试图以编程方式获取不同的用户收件箱(参见下面的代码

)。它工作正常,除了登录行似乎总是登录到我的本地帐户而不是登录到网络上的其他

帐户。有人知道如何使用这种方法登录其他人的

帐户吗?


//创建Outlook应用程序

Outlook .Application oApp = new Outlook.Application();


//获取MAPI命名空间

Outlook.NameSpace oNS = oApp.GetNamespace(" mapi") ;


oNS.Logon(" user"," password",false,true);


//获取消息集合收件箱

Outlook.MAPIFolder oInbox =

oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderInbox);


Outlook.Items oItems = oInbox.Items;


int intTotalNumberOfItemsInInbox = oItems.Count;


//获取未读电子邮件

oItems = oItems.Restrict(" [Unread] = true");

int intTotalUnread = oItems.Count;


***发送来自Developersdexhttp://www.developersdex.com***
I am trying to get at different users inboxes programmatically (see code
below). It works fine, except for the fact that the logon line seems to
always logon to my local account rather than logging on to other
accounts on the network. Anybody know how to logon to other people''s
accounts using this method?

//Create Outlook application
Outlook.Application oApp = new Outlook.Application();

//Get MAPI namespace
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

oNS.Logon("user", "password", false, true);

//Get Messages collection of Inbox
Outlook.MAPIFolder oInbox =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderInbox);

Outlook.Items oItems = oInbox.Items;

int intTotalNumberOfItemsInInbox = oItems.Count;

//Get unread e-mail messages
oItems = oItems.Restrict("[Unread] = true");
int intTotalUnread = oItems.Count;

*** Sent via Developersdexhttp://www.developersdex.com***



< identity impersonate =" true" />





<identity impersonate="true"/>

?


身份模仿可用于硬编码单个用户的登录

详细信息,但我希望能够有一个用户的情况

页面可以从下拉列表中选择一个用户,并且可以访问他们的

电子邮件。


***通过Developersdex http://www.developersdex.com ***
Identity impersonate could be used to hard code a single user''s login
details, but I want to be able to have a situation where the user of the
page can select a user from a dropdown and be able to access their
emails.

*** Sent via Developersdex http://www.developersdex.com ***

" Mike P" < mi ******* @ gmail.com写信息

新闻:eT ************** @ TK2MSFTNGP04.phx.gbl ...
"Mike P" <mi*******@gmail.comwrote in message
news:eT**************@TK2MSFTNGP04.phx.gbl...

//创建Outlook应用程序

Outlook.Application oApp = new Outlook.Application();
//Create Outlook application
Outlook.Application oApp = new Outlook.Application();

http://support.microsoft.com/default...US;q257757#kb2


阅读更多信息部分,特别是粗体段落...




生产环境中,这根本不可能有用......

http://support.microsoft.com/default...US;q257757#kb2

Read the "MORE INFORMATION" section, specifically the paragraph in bold...

There''s a very strong possibility that this won''t work at all in a
production environment...


这篇关于以编程方式获取Outlook收件箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆