如何检索邮件项目(Outlook.MailItem)的Outlook文件夹? [英] How to retrieve the Outlook folder of a mail item (Outlook.MailItem)?

查看:1292
本文介绍了如何检索邮件项目(Outlook.MailItem)的Outlook文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 inboxFolder = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox

其他地方在我的代码,我开始做一个foreach循环来提取我从这些MailItems想要的具体信息

Elsewhere in my code, I begin doing a foreach loop to extract specific information I want from these MailItems

foreach (var item in this.inboxFolder.Items)
{
   Outlook.MailItem mailItem = (Outlook.MailItem)item;
   //.... doing stuff here
   string SenderEmail = mailItem.SenderEmailAddress;
   string SenderName = mailItem.SenderName;
   string FolderLocation = mailItem.???;  //how to retrieve folder location?
   //.... more stuff here
}

例如:用户可能已经创建了一个名为测试显示子文件夹下面

For example: A user may have created a subfolder called 'Test' shown below.

推荐答案

你的意思是文件夹路径?使用MAPIFolder.FullFolderPath。或者MAPIFoldert.Name如果你只需要的名字。

Do you mean folder path? Use MAPIFolder.FullFolderPath. Or MAPIFoldert.Name if you only need the name.

在心中也保持该值将成为该文件夹中的所有项目一样,所以没有理由评估它在循环的每个步骤

Also keep in mind that the value will be the same for all items in the folder, so there is no reason to evaluate it on each step of the loop.

这篇关于如何检索邮件项目(Outlook.MailItem)的Outlook文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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