归档Outlook(它必须存储在本地磁盘中) [英] Archive the outlook (It has to be stored in Local disk )

查看:142
本文介绍了归档Outlook(它必须存储在本地磁盘中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码。但是我收到了错误(

I have the below code . but i am getting error (

尝试的操作失败。找不到对象。在$。$ b  在Microsoft.Office.Interop。 Outlook.FoldersClass.get_Item(Object Index) )。请告诉我该怎么做。 

The attempted operation failed.  An object could not be found.
   at Microsoft.Office.Interop.Outlook.FoldersClass.get_Item(Object Index)  ) . Please advice me how to do . 

          Outlook.Application App = null;

            Outlook.MAPIFolder Source = null;

            Outlook.MAPIFolder Target = null;

         Outlook.Application App = null;
            Outlook.MAPIFolder Source = null;
            Outlook.MAPIFolder Target = null;

App = new Outlook.Application();

                Source = App.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

                Target = App.Session.Folders [" Archive"];

                //循环浏览文件夹商品

                for(int i = Source.Items.Count; i> 0; i--)

                {

                    //移动项目¥b $ b                      Source.Items [i] .Move(Target);

                }

App = new Outlook.Application();
                Source = App.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
                Target = App.Session.Folders["Archive"];
                //loop through the folders items
                for (int i = Source.Items.Count; i > 0; i--)
                {
                    //move the item
                     Source.Items[i].Move(Target);
                }

推荐答案

你好
ain_90,

你曾经提到过,"它必须存储在本地磁盘中"

you had mentioned that,"It has to be stored in Local disk"

你的意思是你想循环浏览文件夹中的邮件并将其存储在文件夹中吗?

do you mean you want to loop through the mail items in folder and store it in folder?

如果是,请尝试参考下面的示例。

if yes , try to refer example below.

static void Main(string[] args)
        {
            Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
           
            Outlook.NameSpace objns = app.GetNamespace("MAPI");

         
            string path;
            int i = 0;

            objns = app.GetNamespace("MAPI");
         
            Outlook.Folder folder = app.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)as Outlook.Folder;
            foreach (Outlook.MailItem item in folder.Items)
            {path= @"C:\Users\v-padee\Desktop\save_mail\" + i + ".msg";
                item.SaveAs(path, Outlook.OlSaveAsType.olMSG);
                i = i + 1;
            }


        }

输出:

问候

Deepak


这篇关于归档Outlook(它必须存储在本地磁盘中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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