Outlook 对象模型 - 检测邮箱 [英] Outlook Object Model - Detecting Mailboxes

查看:29
本文介绍了Outlook 对象模型 - 检测邮箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有以下代码的 Delphi 2006 BDS 应用程序来迭代 Outlook 邮箱,然后是邮箱中的收件箱和已发送项目:

I have a Delphi 2006 BDS application with the following code to iterate outlook mailboxes and then the Inbox and Sent Items within the mailbox:

  try
    nameSpace := outlook.GetNameSpace('MAPI');
    // load the mailboxes
    mailbox := NameSpace.Folders;

    for i := 1 to mailbox.Count do
      if Pos('MAILBOX', UpperCase(mailbox.Item[i].Name)) > 0 then
      begin
        rootNode := trvwOutlookFolders.Items.AddChildObject(nil, mailbox.Item[i].Name, nil);

        for j := 1 to mailbox.Item[i].Folders.Count do
          if (Pos('INBOX', UpperCase(mailbox.Item[i].Folders[j].Name)) > 0) or
             (Pos('SENT ITEMS', UpperCase(mailbox.Item[i].Folders[j].Name)) > 0) then
          begin
        // do processing
          end;

      end;

  finally
    outlook := Unassigned;
  end;
end;

该代码在 Outlook 2007 下可以正常工作,但在 2010 年不行,因为邮箱不包含邮箱"一词.因此,我正在寻找一种替代方法,即从 Outlook 及其后续收件箱和已发送邮件文件夹中提取邮箱(而不是公用文件夹等).有什么想法吗?

The code works fine under Outlook 2007 but doesn't in 2010 because the mailboxes do not contain the word 'Mailbox'. Therefore I am after an alternative method of extracting JUST the mailboxes (not public folders etc) from within Outlook and their subsequence Inbox and sent items folders. Any ideas?

推荐答案

Outlook 中的文件夹可以键入并具有 DefaultItemType 属性.更换

In Outlook folders can be typed and have a DefaultItemType property. Replacing

if Pos('MAILBOX', UpperCase(mailbox.Item[i].Name)) > 0 then

if (mailbox.Item[i].DefaultItemType = olMailItem) then

应该为您提供默认情况下仅存储邮件的文件夹.

should give you the folders that by default store only mail messages.

邮件消息当然也可以存储在无类型文件夹中,但正如 olMailItem 有

Mail messages can of course be stored in untyped folders as well, but as olMailItem has

olMailItem = $00000000;

作为它的值,它也是所有无类型文件夹的默认值.因此,默认情况下,任何无类型文件夹基本上都存储邮件项目.

as its value, it is the default for all untyped folders as well. So basically any untyped folder by default stores mail items.

这篇关于Outlook 对象模型 - 检测邮箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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