Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使Outlook中的文件夹不在现有文件夹C#VSTO下?_Outlook_Vsto_Outlook Addin - Fatal编程技术网

如何使Outlook中的文件夹不在现有文件夹C#VSTO下?

如何使Outlook中的文件夹不在现有文件夹C#VSTO下?,outlook,vsto,outlook-addin,Outlook,Vsto,Outlook Addin,我想在我的用户名下创建一个文件夹。我知道如何在“收件箱”或任何其他框下进行此操作。但是如何在收件箱、已发送邮件等旁边创建一个。 现在我有这个代码: { int Count = 0; Outlook.Application app = Globals.ThisAddIn.Application; Outlook.Folder folder = app.Session.GetDefaultFolder(

我想在我的用户名下创建一个文件夹。我知道如何在“收件箱”或任何其他框下进行此操作。但是如何在收件箱、已发送邮件等旁边创建一个。 现在我有这个代码:

 {
            int Count = 0;
            Outlook.Application app = Globals.ThisAddIn.Application;
            Outlook.Folder folder = app.Session.GetDefaultFolder(
            Outlook.OlDefaultFolders.olFolderInbox) as Outlook.Folder;
            Outlook.Folders folders = folder.Folders;
            Regex FolderCheck = new Regex("MyFolder1");


            foreach (Outlook.Folder folder1 in folders )
            { 

                Count += FolderCheck.Matches(folder1.Name).Count;
            }
            try
            { 
                if (Count == 0)
                {
                    Outlook.Folder PRISKaust = folders.Add("MyFolder1", Type.Missing) as Outlook.Folder;
                    Outlook.Folders PrisKaustSees = PRISKaust.Folders;
                    Outlook.Folder INPRIS1 = PrisKaustSees.Add("MyFolder2", Type.Missing) as Outlook.Folder;


                }
            }
            catch
            {
                MessageBox.Show(
"Error apeared in creating folder", "Folderite Lisamine",
                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
它在收件箱下创建MyFolder1。和
Myfolder1
下的
MyFolder2
。但是路径需要如下:
username@domain.com/MyFolder1/MyFolder2


请提供帮助。

像现在一样检索收件箱文件夹,但使用
MAPIFolder.Parent.Folders.Add

收件箱文件夹的父文件夹是商店中最上面的IPM文件夹。

我不太明白。我尝试过:`PRISKaust=MAPIFolder.Parent.folders.Add(FolderName,Type.Missing)作为Outlook.Folder;`但它不起作用。是的,在我的示例中,MAPIFolder代表MAPIFolder Outlook对象的一个实例,例如代码中的文件夹变量yourFolder=folder.Parent.Folders.Add(“我的新文件夹”);