/// <summary> /// Populates the extended data for a message /// </summary> /// <param name="message"></param> private void PopulateData(OutlookStorage.Message message) { data.Text = ""; foreach (string key in message.streamStatistics.Keys) { string hexKey = key.Substring(12, 4); try { object property = message.GetMapiProperty(hexKey); if (property == null) { data.AppendText((string.Format("Key {0} is null{1}", hexKey, Environment.NewLine))); } else if (property is byte[]) { data.AppendText(string.Format("Key {0} is a byte array{1}", hexKey, Environment.NewLine)); } else { data.AppendText(string.Format("{0}: {1}{2}", hexKey, property.ToString(), Environment.NewLine)); } } catch { data.AppendText(string.Format("Key {0} threw an exception{1}", hexKey, Environment.NewLine)); } } }
private void loadMessage(OutlookStorage.Message message, TreeNode messageNode) { String str; str = "Outlook Envelope data"; messageNode.Text = str; txtBox.AppendText(str + "\n"); str = "SMTP Routing Header\n " + message.GetMapiProperty("007D").ToString(); messageNode.Text = str; txtBox.AppendText(str + "\n"); str = message.Subject; messageNode.Nodes.Add(str); txtBox.AppendText(str + "\n"); str = "Subject: " + message.Subject; messageNode.Nodes.Add(str); txtBox.AppendText(str + "\n"); /*TreeNode bodyNode = messageNode.Nodes.Add("Body: (double click to view)"); * bodyNode.Tag = new string[] { message.BodyText, message.BodyRTF }; */ str = "Recipients: " + message.Recipients.Count; TreeNode recipientNode = messageNode.Nodes.Add(str); txtBox.AppendText(str + "\n"); HashSet <string> targets = new HashSet <string>(); foreach (OutlookStorage.Recipient recipient in message.Recipients) { // Load SMIME certificates from AD targets.Add(recipient.Email); str = recipient.Type + ": " + recipient.Email; recipientNode.Nodes.Add(str); txtBox.AppendText(str + "\n"); } // Parse out from targets.Add(message.GetMapiProperty("5D01").ToString()); // PidTagSenderEmailAddress // Old style /* * string[] strings = Regex.Split(message.GetMapiProperty("007D").ToString(), Environment.NewLine); // PidTagTransportMessageHeaders, https://interoperability.blob.core.windows.net/files/MS-OXPROPS/%5bMS-OXPROPS%5d.pdf * * foreach (string s in strings) * { * if (s.StartsWith("From:")) * { * Match m = Regex.Match(s, "<(.*)>"); * * if (m.Success) * { * targets.Add(m.Groups[1].Value); * } * } * } */ foreach (string target in targets) { if (!certs.ContainsKey(target)) { X509Certificate2 cert = GetUserCertificateFromAD(target); if (cert != null) { certs.Add(target, cert); } } } str = "Attachments: " + message.Attachments.Count; TreeNode attachmentNode = messageNode.Nodes.Add(str); txtBox.AppendText(str + "\n"); foreach (OutlookStorage.Attachment attachment in message.Attachments) { str = attachment.Filename + ": " + attachment.Data.Length + " bytes"; attachmentNode.Nodes.Add(str); txtBox.AppendText(str + "\n"); // Check for SMIME attachment if (attachment.Filename.Contains("p7m")) { smimefound = true; txtBox.AppendText("==== PKCS#7 Enveloped data ====\n"); parsePKCS7(attachment.Data, attachmentNode); } } str = "Sub Messages: " + message.Messages.Count; TreeNode subMessageNode = messageNode.Nodes.Add(str); txtBox.AppendText(str + "\n"); foreach (OutlookStorage.Message subMessage in message.Messages) { this.loadMessage(subMessage, subMessageNode.Nodes.Add("MSG")); } if (smimefound) { statusBar.Text = "S/MIME attachment(s) found!"; } else { statusBar.Text = "No S/MIME attachment(s) found!"; } }