本文介绍了在Outlook收件箱子文件夹中导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我为将Outlook收件箱子文件夹的名称命名为组合框编写了以下代码

hi i wrote following code for get name of outlook inbox subfolders to combo box

public void LoadEmailFolderCombo(ToolStripComboBox nbFolder)
      {
          OutLook._Application outlookObj = new OutLook.Application();
          OutLook.MAPIFolder emailFolder = (OutLook.MAPIFolder)
           outlookObj.Session.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderInbox);

          if (!nbFolder.Items.Contains("Default"))
          {
              nbFolder.Items.Add("Default");
          }
          foreach (OutLook.MAPIFolder subFolder in emailFolder.Folders)
          {
              if (!nbFolder.Items.Contains(subFolder.Name))
              {
                  nbFolder.Items.Add(subFolder.Name);
              }
          }
      }



但有一个问题,它仅使用收件箱文件夹中的文件夹名称,但不会使用子文件夹旁边的文件夹名称为例,例如,我在收件箱中有1个子文件夹kasun,而在kasun中,我有kasunmit它只需要kasun而不是kasunmit pls告诉我我要尝试的是正确的还是有任何新的方法来实现
谢谢



but there is a problem it takes only names of folders inside the inbox folder but wont take names of folders in side the subfolders as example think that i have 1 subfolder kasun inside the inbox and inside kasun i have kasunmit it takes only kasun not kasunmit pls tell wht i am trying to is correct or is there any new way to do it
thank you

推荐答案

public void GetFoldersInFolder(OutLook.MAPIFolder folder)
   {
     foreach (OutLook.MAPIFolder subFolder in folder.Folders)
           {
               if (!nbFolder.Items.Contains(subFolder.Name))
               {
                   nbFolder.Items.Add(subFolder.Name);
                   GetFoldersInFolder(subFolder);
               }
           }
    }



将此合并到您的"LoadEmailFolderCombo"方法中.

干杯



Incorporate this in your "LoadEmailFolderCombo" method.

Cheers


这篇关于在Outlook收件箱子文件夹中导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 11:25