Example #1
0
        private static void DumpBodyPart(ImapClient client, long uid, ImapBodyPart part)
        {
            const string ItemFormat = "\t{0}:\t{1}";
            System.Console.WriteLine("==========");
            System.Console.WriteLine("MSG PART SECTION [{0}]  ({1} bytes):", part.Section, part.Size);
            System.Console.WriteLine(ItemFormat, "Encoding", part.Encoding);
            System.Console.WriteLine(ItemFormat, "ContentType", part.ContentType.ToString());

            if (!string.IsNullOrEmpty(part.ContentType.CharSet))
            {
                System.Console.WriteLine(ItemFormat, "DATA", "\n");
                var sectionData = client.FetchSection(uid, part, true);
                if (sectionData is string)
                {
                    System.Console.WriteLine(sectionData as string);
                }
                else
                {
                    var arr = sectionData as byte[];
                    System.Console.WriteLine("<< BINARY DATA NOT DUMPED - {0} bytes >>", arr.Length);
                }
                System.Console.WriteLine();
            }
            
            System.Console.WriteLine("----------");
        }