public void AlternateDateTest()
        {
            EmailMessage target = new EmailMessage();
              string fileName = CreateTestEmailFile(testMessageBody.Replace("\nDate: Wed, 07 Feb 2001 16:53:46 -0800\n", "\nDate: 28 Mar 2002 23:52:14 -0000\n"));

              try
              {
            target.LoadFromFile(fileName);
            Assert.AreEqual(2002, target.Date.Year);
            Assert.AreEqual(3, target.Date.Month);
            Assert.AreEqual(28, target.Date.Day);
            Assert.AreEqual(23, target.Date.Hour);
            Assert.AreEqual(52, target.Date.Minute);
            Assert.AreEqual(14, target.Date.Second);
              }
              finally
              {
            File.Delete(fileName);
              }
        }
Example #2
0
        static void Main(string[] args)
        {
            var documentStore = new EmbeddableDocumentStore { ConnectionStringName = "Local" };
              documentStore.Initialize();

              foreach (string fileName in Directory.GetFiles("D:\\UserData\\Mboxes\\Archive1999-2002\\Deleted Items", "*.*", SearchOption.AllDirectories))
              {
            var message = new EmailMessage();
            message.LoadFromFile(fileName);

            using (var session = documentStore.OpenSession())
            {
              if (session.Load<EmailMessage>(message.Id) == null)
              {
            session.Store(message);
            session.SaveChanges();
            Console.WriteLine("Stored: " + message.Id);
              }
            }
              }

              Console.Write("Press any key.");
              Console.ReadKey();
        }
        public void LoadFromFileTest()
        {
            EmailMessage target = new EmailMessage();
              string fileName = CreateTestEmailFile();

              try
              {
            target.LoadFromFile(fileName);
            Assert.AreEqual(testMessageBody, target.RawMessage);
            Assert.AreEqual("Domain name", target.Subject);
            Assert.AreEqual("Joe Executive", target.From.Name);
            Assert.AreEqual("*****@*****.**", target.From.EmailAddress);
            Assert.AreEqual(3, target.Recipients.Count);
            Assert.AreEqual("Mar Smith", target.Recipients[0].Name);
            Assert.AreEqual("*****@*****.**", target.Recipients[0].EmailAddress);
            Assert.AreEqual("Kar", target.Recipients[1].Name);
            Assert.AreEqual("*****@*****.**", target.Recipients[1].EmailAddress);
            Assert.AreEqual("David", target.Recipients[2].Name);
            Assert.AreEqual("*****@*****.**", target.Recipients[2].EmailAddress);
            Assert.AreEqual(2001, target.Date.Year);
            Assert.AreEqual(2, target.Date.Month);
            Assert.AreEqual(8, target.Date.Day);
            Assert.AreEqual(0, target.Date.Hour);
            Assert.AreEqual(53, target.Date.Minute);
            Assert.AreEqual(46, target.Date.Second);
              }
              finally
              {
            File.Delete(fileName);
              }
        }