兑换无法将项目添加到文件夹 [英] Redemption Cannot add Item to Folder

查看:25
本文介绍了兑换无法将项目添加到文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Redemption 在 C# 中编写一个程序来遍历 RDOPstStore 中的 RDOMail 对象,并复制标记为与新 RDOPstStore 相关的对象.我可以修改 RDOPstStore.IPMRootFolder 中的文件夹,这样做只会留下一个文件夹(结果).但是,当我将 RDOMail 项目添加到此文件夹(之前保存在列表中)时,这些项目不会出现在文件夹 Items 成员中.为了确保添加的"RDOMMail 对象保存在 RDOPstStore 对象中,我是否遗漏了什么?这是代码

I'm writing a program in C# using Redemption to iterate through the RDOMail objects in a RDOPstStore and copy the ones marked as relevant to a new RDOPstStore. I can modify the folders in the RDOPstStore.IPMRootFolder, and do so to only leave one folder (Results). However when I go to add RDOMail items to this folder (saved in a list previously) the items do not appear in the folders Items member. Is there something I am missing in order to ensure the "added" RDOMail object is saved in the RDOPstStore object? Here is the code

//create an output session 
RDOSession outputSession = new RDOSession(@"Redemption.RDOSession");

//logon/create output store
outputStore = outputSession.LogonPstStore(outputDir + '\\' + filename);

//clear the output store of any folders, we will leave only one: Results
foreach (RDOFolder folder in outputStore.IPMRootFolder.Folders)
{
       folder.Delete(); //successful
}
RDOFolder resultsFolder = outputStore.IPMRootFolder.Folders.Add("Results");

foreach(RDOMail mail in relevantItems) //relevantItems gathered previously
{
        resultsFolder.Items.Add(mail); //unsuccessful
        resultsFolder.Save();
}

/******************EDIT 5/26****************/
outputStore.Save();
outputSession.Logoff();
/******************END EDIT*****************/

非常感谢所有帮助!

推荐答案

好的,所以我能够发现问题.@Dmitry Streblechenko 是对的,我不需要在登录 Pst 存储后添加新的 PST 存储(必要时创建一个新文件).

OK so I was able to discover the issue. @Dmitry Streblechenko was right that I did not need to add a new PST Store after logging onto the Pst Store (which creates a new file if necessary).

但真正的问题是将文件复制到新创建的 PST 存储.问题是使用 RDOFolder.Items.Add(RDOMail) 函数.与此 Add() 函数一样直观,使用 RDOMail.CopyTo(RDOMail/RDOFolder) 函数可能是正确(或至少有效)的方法.原来如此……

BUT the true issue was in copying files to the newly created PST Store. The problem was using the RDOFolder.Items.Add(RDOMail) function. As intuitive as this Add() function may be the correct (or at the very least effective) approach is to use the RDOMail.CopyTo(RDOMail/RDOFolder) function. As so...

mail.CopyTo(resultsFolder);

这成功地将 RDOMail 对象放入 RDOFolder 对象中,而 Add() 函数则不会.作为旁注,我阅读了@Dmitry 帮助的另一篇文章,他提到 Add() 函数用于创建新项目,因此它可能并非完全无用.虽然似乎可以创建一个新的 RDOMail 对象,修改它,然后使用它的 CopyTo() 函数...

This successfully placed the RDOMail object into the RDOFolder object, whereas the Add() function wouldn't. As a side note I read up another post @Dmitry helped on and he mentions that the Add() function is used to create new items, so it may not be completely useless. Although it seems that one could create a new RDOMail object, modify it, then use it's CopyTo() function...

经验教训.

这篇关于兑换无法将项目添加到文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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