1
我一直试图找到一种方法,一个文件夹从C#从Outlook在C#中添加文件夹到PST文件
添加到PST文件我已经尝试了一大堆代码,试图让这工作,这是似乎是最likly是正确的一个(因为它是在MSDN什么),但仍然无法正常工作
Main {
Outlook._Application OutlookObject = new Outlook.Application();
Outlook.Store NewPst = null;
// create the pst file
string pstlocation = "C:\\Users\\Test\\Desktop\\PST\\Test.pst";
try
{
OutlookObject.Session.AddStore(pstlocation);
foreach (Outlook.Store store in OutlookObject.Session.Stores)
{
if (store.FilePath == pstlocation)
{
// now have a referance to the new pst file
NewPst = store;
Console.WriteLine("The Pst has been created");
}
}
}
catch
{ }
// create a folder or subfoler in pst
Outlook.MAPIFolder NewFolder;
NewFolder = NewPst.Session.Folders.Add("New Test Folder", Type.Missing);
}
这段代码创建一个新的PST文件,然后改掉添加一个文件夹但是最后一行代码:
New NewFolder = NewPst.Session.Folders.Add("New Test Folder", Type.Missing);
获取错误“操作失败。”和“无效的转换异常”能有人指出我所事先做错了
感谢
非常感谢您的帮助这解决了我的问题 – jgok222 2012-04-03 14:20:01