从 Outlook 获取收件箱

发布于 2024-11-26 15:59:45 字数 278 浏览 0 评论 0原文

我在 Outlook 2010 中配置了两个 Exchange 帐户,但是我无法找到如何访问第二个帐户的收件箱。 Session.GetDefaultFolder() 始终返回第一个。

即使枚举 Session.Accounts,找到正确的帐户并调用 Session.Account(found one).Store.GetDefaultFolder() 返回错误的收件箱(来自默认交换帐户,而不是次要)。

I configured two Exchange accounts in Outlook 2010, however I cant find out how to get to Inbox of the second account. Session.GetDefaultFolder() always return the first one.

Even enumerating Session.Accounts, finding the right account and calling Session.Account(found one).Store.GetDefaultFolder() returns wrong Inbox (from the default exchange account, not the secondary).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

倦话 2024-12-03 15:59:46

也许您早已放弃了这个问题,但这里...

我以前也遇到过同样的问题,我通过添加 Outlook 帐户管理 API 解决了它。不幸的是,这是一个面向 C++ 的 API。 (我的插件已经用 C++ 开发)

此外,VBA 和 .NET 插件使用的 OOM(Outlook 对象模型)对多个帐户的支持很差(如果有的话)。通过添加交换帐户,您实际上已将多个帐户添加到您的个人资料中。

因此,您可能需要降低一个级别,使用 MAPI 和 C++,然后挂钩 Outlook 帐户管理 API。这是一项繁重的工作,但这正是我所做的,而且效果非常好。

另外,这里有一个例子:
http://www.codeproject.com/KB/IP/IOlkAccountManager.aspx

Maybe you have long given up on this question, but here goes...

I've had this same problem before and I solved it by adding the Outlook Account Management API. Unfortunately for you, this a c++ oriented API. (My addin was already developed in c++)

Furthermore, the OOM (Outlook Object Model) which VBA and the .NET addins use has poor (if any) support for multiple accounts. By adding to exchange accounts, you have essentially added multiple accounts to your profile.

So, You might have to go down a level, using MAPI with c++ and then hook in the Outlook Account Management API. It's a lot of work, but that's exactely what I did and it worked like a charm.

Also, here is an example:
http://www.codeproject.com/KB/IP/IOlkAccountManager.aspx

秋凉 2024-12-03 15:59:46

我想这是一个旧的,但有一天可能有人需要它。
以下是迭代 Outlook 中所有“已发送邮件”文件夹的代码。 (我认为这仅适用于 Outlook 2010 及更高版本)。

MSOutlook._NameSpace ns = Globals.ThisAddIn.Application.GetNamespace("MAPI");
var accounts = ns.Accounts;
foreach (MSOutlook.Account account in accounts)
{
    try
    {
        // You might want to test if DeliveryStore is null, in case this account is not an Exchange account
        MSOutlook.MAPIFolder sentFolder = account.DeliveryStore.GetDefaultFolder(MSOutlook.OlDefaultFolders.olFolderSentMail);
        if(sentFolder != null)
        {
            SentItems = sentFolder.Items;
            SentItems.ItemAdd += LogMethods.Items_Sent_ItemAdd;
        }
    }
    catch (Exception e)
    {
        BaseClass.log.Log(LoggLevel.Warning, e.Message);
    }
}

I guess this is an old one, but somebody might need it one day.
Here is code to iterate all "Sent Mail" folders in Outlook. (I think this will only work for Outlook 2010 and newer).

MSOutlook._NameSpace ns = Globals.ThisAddIn.Application.GetNamespace("MAPI");
var accounts = ns.Accounts;
foreach (MSOutlook.Account account in accounts)
{
    try
    {
        // You might want to test if DeliveryStore is null, in case this account is not an Exchange account
        MSOutlook.MAPIFolder sentFolder = account.DeliveryStore.GetDefaultFolder(MSOutlook.OlDefaultFolders.olFolderSentMail);
        if(sentFolder != null)
        {
            SentItems = sentFolder.Items;
            SentItems.ItemAdd += LogMethods.Items_Sent_ItemAdd;
        }
    }
    catch (Exception e)
    {
        BaseClass.log.Log(LoggLevel.Warning, e.Message);
    }
}
奢欲 2024-12-03 15:59:45

这是否显示了所有可用的收件箱?

Sub LoopThroughInboxes

Dim ol As Outlook.Application
Dim ns As Outlook.NameSpace
Dim i As Long

Set ol = Outlook.Application
Set ns = ol.GetNamespace("MAPI")

For i = 1 To ns.Folders.Count
 Debug.Print ns.Folders(i).Name
Next i

如果是这样,那么 ns.Folders(i).Folders("Inbox") 将为您提供每个邮箱的收件箱。

Does this show you all the available Inboxes?

Sub LoopThroughInboxes

Dim ol As Outlook.Application
Dim ns As Outlook.NameSpace
Dim i As Long

Set ol = Outlook.Application
Set ns = ol.GetNamespace("MAPI")

For i = 1 To ns.Folders.Count
 Debug.Print ns.Folders(i).Name
Next i

If so then ns.Folders(i).Folders("Inbox") will get you the Inbox for each mailbox.

夜清冷一曲。 2024-12-03 15:59:45

使用 Store.GetDefaultFolder 而不是 Namespace.GetDefaultFolder
请注意,Store.GetDefaultFolder 是在 Outlook 2010 中添加的。在早期版本的 Outlook 中,使用扩展 MAPI(C++ 或 Delphi)或 救赎(我是其作者)- RDOStore.GetDefaultFolder

Use Store.GetDefaultFolder instead of Namespace.GetDefaultFolder.
Note that Store.GetDefaultFolder was added in Outlook 2010. In the earlier versions of Outlook use Extended MAPI (C++ or Delphi) or Redemption (I am its author) - RDOStore.GetDefaultFolder.

橘虞初梦 2024-12-03 15:59:45

转到 Mapix 库

Mapix 库链接如下所示

C++/MFC 的 Mapix 库

注意:< /strong> 该库适用于 MS Outlook 中的收件箱电子邮件

To Go to Mapix library

Mapix library link as given below

Mapix library for C++/MFC

Note: This Library valid for Inbox emails in MS Outlook

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文