本文介绍了Microsoft Exchange Web服务读取我的本地Outlook文件夹INSTEAD的另一个地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了我认为是网络上每种解决方案的东西,但是还没有找到,所以去吧.

I've searched for what I think is every type of solution on the net but haven't found it, so here goes.

我的应用程序使用Exchange Web Services API 2.0,它旨在读取[email protected]的电子邮件地址.该应用程序旨在读取ProdSupport的收件箱,并将其移动到一个名为"Staging"的自定义创建的文件夹中.我可以阅读ProdSupport收件箱中的电子邮件.

My application uses Exchange Web Services API 2.0 and it's designed to read the Email address of [email protected]. The app is designed to read into ProdSupport's Inbox and move it to a Custom created folder called "Staging". I AM ABLE to read into the emails of ProdSupport's Inbox.

问题是,当我遍历FindFolders()时,我不知道如何读入ProdSupport的电子邮件文件夹列表.我见过的所有示例都使用WellKnownFolderName,但这不适用于自定义文件夹".当我确实移动电子邮件时,会将其从ProdSupport的收件箱"移动到我的本地([email protected])暂存电子邮件"文件夹,而不是ProdSupport的暂存电子邮件文件夹.有什么想法吗?

Problem is, I don't know how to read into ProdSupport's list of email folders when I iterate through FindFolders(). All the examples I've seen use WellKnownFolderName but this won't work for a Custom Folder. When I do move an email, it moves it from the ProdSupport's Inbox to MY local([email protected]) Staging Email folder instead of ProdSupport's Staging Email folder. Any ideas on what's happening?

我尝试将FindResults变量的parentFolderId(我认为是根文件夹")字符串传递给FolderID对象,并使用FindFolders(),但没有结果.我需要知道如何导航和访问[email protected]的此自定义暂存电子邮件"文件夹

I've tried passing the parentFolderId(which I thought was the Root Folder) string of the FindResults variable to a FolderID object and using FindFolders() but get no results. I need to know how to navigate to and access this custom "Staging Email" folder of [email protected]

我拥有所有访问权限,因为我可以作为组的一部分来创建文件夹/修改名称ProdSupport.希望我的解释不会引起任何混乱.下面的代码:

I have all access rights as I can create folders/modify names ProdSupport as I'm part of the Group. Hopefully I didn't create any confusion by my explanation. Code below:

enter code here
this.Service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
Service.UseDefaultCredentials = false;
Service.Credentials = new WebCredentials("myUserID", "myPassword", "myOutlookDomain");

Mailbox ProdSupportMailbox = new Mailbox("[email protected]");
Service.AutodiscoverUrl("[email protected]");

View = new ItemView(40);
View.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties,
                   EmailMessageSchema.From,
                                   EmailMessageSchema.IsRead);

FindResults = Service.FindItems(new FolderId(WellKnownFolderName.Inbox, ProdSupportMailbox), View);

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

FolderView = new FolderView(100);
FolderView.PropertySet = new PropertySet(BasePropertySet.IdOnly);
FolderView.PropertySet.Add(FolderSchema.DisplayName);
FolderView.Traversal = FolderTraversal.Deep;


foreach (Folder folder in rootfolder.FindFolders(FolderView))
            {

                if (folder.DisplayName == "Staging Folder") // I cannot read this folder that I need access to for [email protected]

                // if (folder.DisplayName == "Staging Email local") // I can read this folder which is my local folder name([email protected])
                {
                    stores it in a variable
                    var fid = folder.Id;
                    Console.WriteLine(fid);


                }

推荐答案

感谢您的帮助Glen.原来,我只是指向错误的上下文,我只需要将FolderID指向与收件箱"相同的邮箱:

Thanks for your help Glen. Turns out I was just pointing to the wrong context and I just needed to point the FolderID to the same Mailbox as the Inbox in:

FindResults = Service.FindItems(new FolderId(WellKnownFolderName.Inbox,ProdSupportMailbox),View);

FindResults = Service.FindItems(new FolderId(WellKnownFolderName.Inbox, ProdSupportMailbox), View);

FolderView只是具有设置属性的空对象.

FolderView was just an empty object with set properties.

var FolderResults = Service.FindFolders(new FolderId(WellKnownFolderName.Root,ProdSupportMailbox),FolderView);

var FolderResults = Service.FindFolders(new FolderId(WellKnownFolderName.Root, ProdSupportMailbox), FolderView);

这篇关于Microsoft Exchange Web服务读取我的本地Outlook文件夹INSTEAD的另一个地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 19:12