programaticaly在addin关闭进程中创建了outlook文件夹 [英] programaticaly created outlook folder not deleting at addin shutdown process
问题描述
我使用以下代码创建了一个文件夹,此文件夹没有保留任何其他文件/文件夹,正用于显示某些html页面格式。
I created one folder by using following code, this folder is not keeping any other file/folder, is being used for display some html page format.
nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Folders.Add(QUOT;关系Dashboard与QUOT ;, Outlook.OlDefaultFolders.olFolderInbox);
nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Folders.Add("Relations Dashboard", Outlook.OlDefaultFolders.olFolderInbox);
以及在插件关闭,该文件夹需要删除,所以早些时候我通过代码删除它,它会删除项目文件夹,但永久删除,因为我发现在网络上的建议,先移动到已删除的项目文件夹,然后删除
来自那里。
well at addin shutdown, that folder needed to be deleted, so earlier when I was deleting it through code, it was going to deleted items folder, but for permanent delete, as I found suggestion on the net to first move to deleted items folder and then delete it from there.
所以使用以下代码,
checkFolder = nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Folders [" Relations信息中心"];&
    
Outlook.MAPIFolder l_TrashFolder1 = nameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderDeletedItems);
nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Folders [" Relations Dashboard"]。MoveTo(l_TrashFolder1);
checkFolder = nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Folders["Relations Dashboard"];
Outlook.MAPIFolder l_TrashFolder1 = nameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderDeletedItems);
nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Folders["Relations Dashboard"].MoveTo(l_TrashFolder1);
然后代码永久删除,
的foreach(Outlook.Folder FLDR在Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderDeletedItems).Folders)
          &NBSP ; {
试试
{
如果(fldr.Name.Equals(QUOT;关系信息中心"))
             &NBSP ;      {
                &NBSP ;       for(int i = fldr.Items.Count; i> 0; i - ) //这里fldr.Items.Count为零,这很明显,因为这个文件夹
没有其他项目//
  ;                {
                    &NBSP ;       fldr.Items.Remove(ⅰ);
                &NBSP ;       }
                &NBSP ;       fldr.Delete(); //行 - **
  }
}
catch(System.Exception e1)
{
MessageBox.Show(e1.Message);
}
}
这不是删除文件夹并在线提供例外 - **
foreach (Outlook.Folder fldr in Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderDeletedItems).Folders)
{
try
{
if (fldr.Name.Equals("Relations Dashboard"))
{
for (int i = fldr.Items.Count; i > 0; i--) // here fldr.Items.Count is zero, which is obvious because this folder
has no other item//
{
fldr.Items.Remove(i);
}
fldr.Delete(); // line-**
}
}
catch (System.Exception e1)
{
MessageBox.Show(e1.Message);
}
}
this is not deleting folder and giving exception on line -**
" 无法删除此文件夹。右键单击该文件夹,然后单击"属性"以检查该文件夹的权限。查看文件夹所有者或管理员以更改您的权限。"
"Cannot delete this folder. Right-click the folder, and then click Properties to check your permissions for the folder. See the folder owner or your administrator to change your permissions. "
有趣的是,当我搬家时将删除项目中的文件夹删除到addin启动过程的下半部分代码,它可以工作,
well interesting thing is that when i move this lower part of code of deleting folder from deleted items to the addin startup process, it works,
任何想法..我需要在addin关机时永久地调整文件夹,以防万一卸载插件时,此文件夹不应该在那里。
any idea..as i need to tremove folder permanently at addin shutdown, so that in case of uninstalling addin , this folder should not be there.
感谢并等待紧急响应。
推荐答案
嗨Mehnaz’ 13,
感谢您发帖MSDN论坛。
C 你能不能告诉我 你的版本 r Outlook?
据我知道的,的ThisAddIn_Shutdown不会在正常情况下工作在 前景的
2010。这是一篇博客文章, 讨论了这个问题:
http://blogs.msdn.com/b/rgregg/archive/2009/10/02/additional-shutdown-changes-for-outlook-2010-beta.aspx
。我希望它有所帮助。
Could you tell me what is the version of your Outlook? As far as I know, the ThisAddIn_Shutdown will not work in normal situation on outlook 2010. Here is a blog article which discusses this issue: http://blogs.msdn.com/b/rgregg/archive/2009/10/02/additional-shutdown-changes-for-outlook-2010-beta.aspx . I hope it helps.
度过美好的一天,
Tom Xu
这篇关于programaticaly在addin关闭进程中创建了outlook文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!