public void CanGetMailFromFolder()
        {
            var testDir = new DirectoryInfo(@"D:\Mail\samples");
            var folder  = new MailFolder(testDir);
            var items   = folder.GetMailItems();

            Assert.Equal(items.Count, testDir.GetFiles("*.eml").Length);
            Assert.True(items.Any());
        }
Example #2
0
        private IEnumerable <SimpleMail> GetSimpleMail()
        {
            var result = new List <SimpleMail>();
            var folder = new MailFolder(new DirectoryInfo(ConfigurationManager.MailPath));

            foreach (var item in folder.GetMailItems())
            {
                var mime = item.Value;
                result.Add(new SimpleMail
                {
                    To          = mime.To.ToString(),
                    From        = mime.From.ToString(),
                    File        = item.Key.Name,
                    Subject     = mime.Subject,
                    Attachments = mime.Attachments.Count(),
                    Received    = mime.Date.DateTime
                });
            }
            return(result);
        }