//ExEnd:SourceOutlookFilePath /// <summary> /// Gets Outlook email file's metadata /// </summary> public static void GetOutlookEmailMetadata() { try { //ExStart:GetOutlookEmailMessageMetadata // initialize outlookFormat using (OutlookMessage msgFormat = new OutlookMessage(Common.MapSourceFilePath(filePath))) { // get metadata OutlookMessageMetadata metadata = msgFormat.GetMsgInfo(); // display metadata Console.WriteLine("Body: " + metadata.Body); Console.WriteLine("DeliveryTime: " + metadata.DeliveryTime); Console.WriteLine("Recipients: " + metadata.Recipients[0]); Console.WriteLine("Subject: " + metadata.Subject); Console.WriteLine("Attachments: " + metadata.Attachments[0]); } //ExEnd:GetOutlookEmailMessageMetadata } catch (Exception exp) { Console.WriteLine(exp.Message); } }
private List <PropertyItem> AppendMetadata(OutlookMessageMetadata metadataArray, List <PropertyItem> values) { foreach (MetadataProperty metadataPropert in metadataArray) { if (metadataPropert.Value != null) { if (!metadataPropert.Value.Type.ToString().Equals("StringArray")) { values.Add(new PropertyItem(metadataPropert.Name, metadataPropert.Value.ToString(), metadataPropert.IsBuiltInProperty)); } else { string strValues = "[" + metadataPropert.Value.ToStringArray().Count().ToString() + "] - "; foreach (string str in metadataPropert.Value.ToStringArray()) { strValues += str + " ,"; } values.Add(new PropertyItem(metadataPropert.Name, strValues.Trim(','), metadataPropert.IsBuiltInProperty)); } } } return(values); }