本文介绍了Outlook收件箱并将项目分配到C#Windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#winforms应用程序中配置或显示Outlook2007(收件箱和发送项目).
还为客户制作文件夹.
将与邮件相关的客户端保存到该特定客户端文件夹.
请您帮忙???
请告诉我.
感谢

how to configure or display outlook2007 (inbox and send items) in C# winforms application.
also making folders for client.
saving mail related client to that specific client folder.
plz can u help???
plz tell me .
thanks

推荐答案

public static void GetOutlookItems(string subFolderName)
      {
          Microsoft.Office.Interop.Outlook.Application app = null;
          Microsoft.Office.Interop.Outlook._NameSpace ns = null;
          Microsoft.Office.Interop.Outlook.PostItem item = null;
          Microsoft.Office.Interop.Outlook.MAPIFolder inboxFolder = null;
          Microsoft.Office.Interop.Outlook.MAPIFolder subFolder = null;

          try
          {
              app = new Microsoft.Office.Interop.Outlook.Application();
              ns = app.GetNamespace("MAPI");

              // The following line will begin the install wizard for Outlook if not installed.
              ns.Logon(null, null, false, false);

              inboxFolder = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
              //subFolder = inboxFolder.Folders[subFolderName];
              subFolder = inboxFolder.Folders[1];// also works-- which folder?
              Console.WriteLine("Folder Name: {0}, EntryId: {1}", subFolder.Name, subFolder.EntryID);
              Console.WriteLine("Num Items: {0}", subFolder.Items.Count.ToString());

              for (int i = 1; i <= subFolder.Items.Count; i++)
              {
                  item = (Microsoft.Office.Interop.Outlook.PostItem)subFolder.Items[i];
                  Console.WriteLine("Item: {0}", i.ToString());
                  Console.WriteLine("Subject: {0}", item.Subject);
                  Console.WriteLine("Sent: {0} {1}", item.SentOn.ToLongDateString(), item.SentOn.ToLongTimeString());
                  Console.WriteLine("Categories: {0}", item.Categories);
                  Console.WriteLine("Body: {0}", item.Body);
                  Console.WriteLine("HTMLBody: {0}", item.HTMLBody);
              }
          }
          catch (System.Runtime.InteropServices.COMException ex)
          {
              Console.WriteLine(ex.ToString());
          }
          finally
          {
              ns = null;
              app = null;
              inboxFolder = null;
          }
      }


这篇关于Outlook收件箱并将项目分配到C#Windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 21:31