gpt4 book ai didi

c# - 从特定文件夹获取 outlook 中的所有邮件

转载 作者:行者123 更新时间:2023-11-30 16:30:26 25 4
gpt4 key购买 nike

我想从特定文件夹中获取 outlook 中的所有邮件:

我的文件夹结构:

My folder structure

我找到这个Code获取 outlook 收件箱文件夹中的所有邮件(不是图片中的收件箱!):

Outlook.Application oApp;
Outlook._NameSpace oNS;
Outlook.MAPIFolder oFolder;
Outlook._Explorer oExp;

oApp = new Outlook.Application();
oNS = (Outlook._NameSpace)oApp.GetNamespace("MAPI");
oFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
oExp = oFolder.GetExplorer(false);
oNS.Logon(Missing.Value, Missing.Value, false, true);

Outlook.Items items = oFolder.Items;
foreach (Outlook.MailItem mail in items)
{
//do someting
}

谁能告诉我如何从特定文件夹(例如:wolfy-server)获取所有邮件?

最佳答案

这应该有效!!!

MAPIFolder mailsFromThisFolder;

MAPIFolder mainFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

foreach (MAPIFolder folder in mainFolder.Folders)
{
GetFolders(folder);
}

public void GetFolders(MAPIFolder folder)
{
if (folder.Folders.Count == 0)
{
if (folder.Name == "Folder Name")
{
Console.WriteLine(m.FullFolderPath);
mailsFromThisFolder = folder;
}
}
else
{
foreach (MAPIFolder subFolder in folder.Folders)
{
GetFolders(subFolder);
}
}
}

Outlook.Items items = mailsFromThisFolder.Items;
foreach (Outlook.MailItem mail in items)
{
//do someting
}

关于c# - 从特定文件夹获取 outlook 中的所有邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5660332/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com