public void TestSaveAttachmentsAndEmail() { int i = 0; var directory = new System.IO.DirectoryInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)); var store = new RfiCoder.Entity.Store(); store.ProjectNumber = 1305015; store.Program = RfiCoder.Enum.ProgramTypes.NewStores; store.City = "Oconomowoc"; do { var email = new Microsoft.Exchange.WebServices.Data.EmailMessage( RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService); email.Subject = @"FW: RFI:Request for Information Answered: TEST"; email.Categories.Add("TEST"); var files = directory.GetFiles(); var randGen = new System.Random(); var pt = randGen.Next(1, files.Length); var file = files[pt]; email.Attachments.AddFileAttachment(file.Name, file.OpenRead()); email.Save(RfiCoder.Utilities.EmailHelper.InstanceOf.NewStoresFolder); i++; } while (i < 5); var itemView = new Microsoft.Exchange.WebServices.Data.ItemView(int.MaxValue); itemView.PropertySet = new Microsoft.Exchange.WebServices.Data.PropertySet(Microsoft.Exchange.WebServices.Data.BasePropertySet.IdOnly, Microsoft.Exchange.WebServices.Data.ItemSchema.Categories); var filter = new Microsoft.Exchange.WebServices.Data.SearchFilter.IsEqualTo(Microsoft.Exchange.WebServices.Data.EmailMessageSchema.Categories, "TEST"); var results = RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService.FindItems(RfiCoder.Utilities.EmailHelper.InstanceOf.NewStoresFolder, filter, itemView); var message = Microsoft.Exchange.WebServices.Data.Item.Bind(RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService, results.Items[0].Id, RfiCoder.Utilities.EmailHelper.EmailProperties ); var result = RfiCoder.Utilities.EmailHelper.InstanceOf.ArchiveAnsweredRfi(message, store); Assert.That(result, Is.True); }
public void TestGetMessagesOfSameCategory() { var view = new Microsoft.Exchange.WebServices.Data.ItemView(int.MaxValue); var items = RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService.FindItems(RfiCoder.Utilities.EmailHelper.InstanceOf.NewStoresFolder, view); var randGen = new System.Random(); var pt = randGen.Next(1, items.TotalCount); var item = items.Items[pt]; var message = Microsoft.Exchange.WebServices.Data.EmailMessage.Bind(RfiCoder.Utilities.EmailHelper.InstanceOf.GetEmailService, item.Id, RfiCoder.Utilities.EmailHelper.EmailProperties ); var results = RfiCoder.Utilities.EmailHelper.InstanceOf.GetMessagesOfSameCategory(message); foreach (var element in results.Items) { Assert.That(message.Categories[0], Is.EqualTo(element.Categories[0])); } }