Spire.Email 教程:从C#,VB.NET中的PST文件获取文件夹信息

PST文件用于存储与Outlook和Exchange程序中保存的电子邮件文件夹、地址、联系信息、电子邮件消息和其他数据相关的信息。 Spire.Email支持读取PST文件并获取文件夹信息,如文件夹名称,消息计数和未读消息计数。

Step 1:将PST文件从磁盘加载到OutlookFile类的实例中。

OutlookFile olf = new OutlookFile(@"C:UsersjackDocumentsOutlook FilesSample.pst");

Step 2:获取文件夹集合。

OutlookFolderCollection folderCollection = olf.RootOutlookFolder.GetSubFolders();

Step 3:遍历集合并获取集合中每个元素的文件夹信息。

foreach (OutlookFolder folder in folderCollection){    Console.WriteLine("Folder: " + folder.Name);    Console.WriteLine("Total items: " + folder.ItemCount);    Console.WriteLine("Total unread items: " + folder.UnreadItemCount);    Console.WriteLine("Whether this folder has subfolders: {0}", (folder.HasSubFolders)Yes":"No");    Console.WriteLine("------------------Next Folder--------------------");}

输出:

图片1

完整代码:

[C#]

OutlookFile olf = new OutlookFile(@"C:UsersjackDocumentsOutlook FilesSample.pst");OutlookFolderCollection folderCollection = olf.RootOutlookFolder.GetSubFolders();foreach (OutlookFolder folder in folderCollection){    Console.WriteLine("Folder: " + folder.Name);    Console.WriteLine("Total items: " + folder.ItemCount);    Console.WriteLine("Total unread items: " + folder.UnreadItemCount);    Console.WriteLine("Whether this folder has subfolders: {0}", (folder.HasSubFolders)Yes":"No");    Console.WriteLine("------------------Next Folder--------------------");}Console.WriteLine("Completed");

[VB.NET]

Dim olf As New OutlookFile("C:UsersjackDocumentsOutlook FilesSample.pst")Dim folderCollection As OutlookFolderCollection = olf.RootOutlookFolder.GetSubFolders()For Each folder As OutlookFolder In folderCollection    Console.WriteLine("Folder: " + folder.Name)    Console.WriteLine("Total items: " + folder.ItemCount)    Console.WriteLine("Total unread items: " + folder.UnreadItemCount)    Console.WriteLine("Whether this folder has subfolders: {0}", If((folder.HasSubFolders), "Yes", "No"))    Console.WriteLine("------------------Next Folder--------------------")NextConsole.WriteLine("Completed")

控件

标签:文档处理电子邮件

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2017年7月15日
下一篇 2017年7月15日

相关推荐

发表回复

登录后才能评论