private static void HandleFolder(pstsdk.definition.pst.folder.IFolder rootfolder, System.Xml.XmlDocument doc, System.Xml.XmlNode node, string currpath, bool unicode) { uint messagecnt = (uint)rootfolder.MessageCount; uint attachcnt = (uint)rootfolder.Messages.Sum(x => x.AttachmentCount); System.Xml.XmlElement folderinfo = doc.CreateElement("folderinfo"); System.Xml.XmlNode folderinfonode = node.AppendChild(folderinfo); System.Xml.XmlElement numofmsg = doc.CreateElement("numOfMsg"); System.Xml.XmlNode numofmsgnode = folderinfonode.AppendChild(numofmsg); numofmsgnode.InnerText = messagecnt.ToString(); System.Xml.XmlElement numofattachments = doc.CreateElement("numOfAttachments"); System.Xml.XmlNode numofattachmentsnode = folderinfonode.AppendChild(numofattachments); numofattachmentsnode.InnerText = attachcnt.ToString(); System.Xml.XmlElement foldername = doc.CreateElement("foldername"); System.Xml.XmlNode foldernamenode = folderinfonode.AppendChild(foldername); System.Xml.XmlAttribute foldernameattrib = doc.CreateAttribute("type"); foldernameattrib.InnerText = unicode == true ? "PT_UNICODE" : "PT_ASCII"; foldernamenode.Attributes.Append(foldernameattrib); // if (currpath == "Root Container") // foldernamenode.InnerText = String.Format("cb: {0} lpb: {1}", 0, string.Empty); // else // { byte[] bytes = null; if (unicode == true) bytes = System.Text.UnicodeEncoding.Unicode.GetBytes(currpath); else bytes = System.Text.UnicodeEncoding.ASCII.GetBytes(currpath); foldernamenode.InnerText = String.Format("cb: {0} lpb: {1}", bytes.Length, bytes.Select(x => String.Format("{0:X2}", x)).Aggregate((i, j) => i + j)); // } System.Xml.XmlElement folderid = doc.CreateElement("folderid"); System.Xml.XmlNode folderidnode = folderinfonode.AppendChild(folderid); folderidnode.InnerText = rootfolder.EntryID.ToString(); }
private static void GetFolderData(pstsdk.definition.pst.folder.IFolder rootfolder, string currpath, bool filtered, bool includemessages, ref List<FolderData> folders) { if (rootfolder.Name != string.Empty) currpath += (currpath != string.Empty ? "\\" : string.Empty) + rootfolder.Name; if (rootfolder.Name == string.Empty) currpath = "Root Container"; FolderData folderdata = null; if ((folderdata = folders.FirstOrDefault(x => (x.FolderPath == currpath) || (x.FolderEntryId == rootfolder.EntryID.ToString()))) != null) { folderdata.NodeId = rootfolder.Node; if(folderdata.FolderEntryId == string.Empty) folderdata.FolderEntryId = rootfolder.EntryID.ToString(); if (folderdata.FolderPath == string.Empty) folderdata.FolderPath = currpath; } else if (filtered == false) folders.Add(folderdata = new FolderData(currpath, rootfolder, includemessages ? (uint)rootfolder.MessageCount : 0, includemessages ? (uint)rootfolder.Messages.Count(x => x.AttachmentCount > 0) : 0)); if (folderdata != null && includemessages == true) { List<MessageData> messagedatalist = folderdata.MessageData; foreach (pstsdk.definition.pst.message.IMessage msg in rootfolder.Messages) { MessageData messagedata = new MessageData(msg.EntryID.ToString(), msg.Node, (uint)msg.AttachmentCount); messagedatalist.Add(messagedata); msg.Dispose(); } } if (rootfolder.Name == string.Empty) currpath = string.Empty; foreach (pstsdk.definition.pst.folder.IFolder folder in rootfolder.SubFolders) { GetFolderData(folder, currpath, filtered, includemessages, ref folders); folder.Dispose(); } }
public MessageData(string entryid, pstsdk.definition.util.primitives.NodeID nodeid, uint numattachments) { this.NumAttachments = numattachments; this.MessageEntryId = entryid; this.NodeId = nodeid; }
public FolderData(string currpath, pstsdk.definition.pst.folder.IFolder folder, uint nummessages, uint numattachments) { this.MessageData = new List<MessageData>(); this.FolderPath = currpath == string.Empty ? "Root Container" : currpath; if (folder != null) { this.FolderEntryId = folder.EntryID.ToString(); this.NodeId = folder.Node; } this.NumAttachments = numattachments; this.NumMessages = nummessages; }
public FolderData(string currpath, pstsdk.definition.pst.folder.IFolder folder) : this(currpath, folder, 0, 0) { }