Example #1
0
        public static void ReadAndPrint()
        {
            if (IsInUse)
            {
                return;
            }
            else
            {
                IsInUse = true;
            }

            var mailRepository = new EMail(
                "imap.gmail.com",
                993,
                true,
                EMail.EMAIL,
                EMail.PASSWORD
                );

            var emailList = mailRepository.GetUnreadMails("inbox");

            foreach (Message email in emailList)
            {
                Console.WriteLine("Count: " + email.Attachments.Count);
                foreach (MimePart n in email.Attachments)
                {
                    string path     = Write.CreateFilePath(Folder.EMAIL_ATTACHMENTS.Path(), true);
                    string fileName = Generate.RandomString(10) + "_" + n.Filename;
                    n.StoreToFile(System.IO.Path.Combine(path, fileName));

                    string fullPath = System.IO.Path.Combine(path, fileName);
                    Console.WriteLine(fullPath);
                    Printer.AddPath(fullPath);
                }
            }

            Printer.Print();

            Console.WriteLine("Read and printed if not null");

            IsInUse = false;
        }