public void TestRoundTripDropAttachments()
		{
			using (WsActivationContext wsac = new WsActivationContext())
			using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession))
			{
				string subject = "Test outlook proxy: TestRoundTripDropAttachments";
				outlookEmailWrapper.Subject = subject;
				outlookEmailWrapper.ToRecipients = "*****@*****.**";
				outlookEmailWrapper.CcRecipients = "*****@*****.**";
				outlookEmailWrapper.BccRecipients = "[email protected];[email protected]";
				outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatRichText;
				string rtfBody = "We have a body that looks like something";
				outlookEmailWrapper.Body = rtfBody;
				outlookEmailWrapper.AddAttachment(m_testPath + "test.doc", "Mickey Mouse", Outlook.OlAttachmentType.olByValue);
				outlookEmailWrapper.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;

				// We have to save the message in order to access all its contents :(
				outlookEmailWrapper.MailItem.Save();

				using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem))
				{
					Assert.AreEqual(1, proxy.Attachments.Count);
					// DE9310, requires to change this test behavior
					Assert.AreEqual("Mickey Mouse", proxy.Attachments[0].DisplayName);
					Assert.AreEqual("application/msword; name=Mickey Mouse", proxy.Attachments[0].ContentType);
					Assert.IsTrue(proxy.Attachments[0].FileName.Contains("test.doc"), "Expected to find a non-empty stream");

					// Lets convert the outlook mail message to MIME
					using (Email2Mime mailItem2Mime = new Email2Mime(proxy))
					using (Stream mimeStream = mailItem2Mime.ConvertToMimeStream())
					using (MimeProxy mimeProxy = new MimeProxy(mimeStream))
					{
						//  Drop the attachments in the MIME stream 
						mimeProxy.Attachments.Clear();

						Email2Request email2Request = new Email2Request(mimeProxy);
						Request request = email2Request.Convert(RequestChannel.Outlook, false);

						outlookEmailWrapper.MailItem.Delete();

						Assert.AreEqual(0, request.Attachments.Length);

						// Synchronise the email with the changes made to the URO
						//Assert.AreEqual(0, proxy.Attachments.Count);
					}
				}
			}
		}
		public void TestConvertToMimeStreamWithAttachmentAddedWhereDisplayNameDoesntHaveExtension()
		{
			using (WsActivationContext wsac = new WsActivationContext())
			using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession))
			{
				string subject = "Plain text e-mail: This is a test mail";
				outlookEmailWrapper.Subject = subject;
				outlookEmailWrapper.ToRecipients = "*****@*****.**";
				outlookEmailWrapper.BccRecipients = "*****@*****.**";
				outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatPlain;
				outlookEmailWrapper.Body = "We have a body that looks like something";
				outlookEmailWrapper.AddAttachment(m_testPath + "test.doc", "test with no extension", Outlook.OlAttachmentType.olByValue);
				outlookEmailWrapper.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow;

                Request request = ConvertToRequestWithAttachment(m_testPath + "TestResultConvertToMimeStreamAddedByValue.txt", "test with no extension", outlookEmailWrapper.MailItem);

				//properties
				Assert.AreEqual(8, request.Properties.Length);
				Assert.AreEqual(String.Empty, GetPropertyValue(MailMessagePropertyKeys.FileHeader, request.Properties), "Mismatch in Property");
				Assert.IsTrue(GetPropertyValue(MailMessagePropertyKeys.Body, request.Properties).Contains("We have a body that looks like something"), "Mismatch in Property");
				Assert.IsTrue(GetPropertyValue(MailMessagePropertyKeys.FormattedBody, request.Properties).Contains("We have a body that looks like something"), "Mismatch in Property");
				Assert.AreEqual(subject, GetPropertyValue(MailMessagePropertyKeys.Subject, request.Properties), "Mismatch in Property");
				Assert.AreEqual("Outlook", GetPropertyValue(SMTPPropertyKeys.RequestChannel, request.Properties), "Mismatch in Property");
				Assert.AreEqual("test with no extension ", GetPropertyValue(MailMessagePropertyKeys.Attachments, request.Properties), "Mismatch in Property");

				Assert.AreEqual("5", GetPropertyValue(MailMessagePropertyKeys.xPriority, request.Properties));
			}
		}
		public void TestConvertToMimeStreamRtfBodyWithAttachmentAddedByRef()
		{
			using (WsActivationContext wsac = new WsActivationContext())
			using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession))
			{
				string subject = "RTF text e-mail: This is a test mail";
				outlookEmailWrapper.Subject = subject;
				outlookEmailWrapper.ToRecipients = "*****@*****.**";
				outlookEmailWrapper.BccRecipients = "*****@*****.**";
				outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatRichText;
				string rtfBody = "We have a body that looks like something";
				outlookEmailWrapper.Body = rtfBody;
				outlookEmailWrapper.AddAttachment(m_testPath + "test.doc", "test.doc", Outlook.OlAttachmentType.olByReference);
				outlookEmailWrapper.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow;

                Request request = ConvertToRequestWithAttachment(m_testPath + "TestResultConvertToMimeStreamRtfBodyAddedByRef.txt", "test.doc", outlookEmailWrapper.MailItem);

				//properties
				Assert.AreEqual(8, request.Properties.Length);
				Assert.AreEqual(String.Empty, GetPropertyValue(MailMessagePropertyKeys.FileHeader, request.Properties), "Mismatch in Property");

				Assert.IsTrue( GetPropertyValue(MailMessagePropertyKeys.Body,request.Properties ).Contains(rtfBody));

				string resultantRtf = GetPropertyValue(MailMessagePropertyKeys.FormattedBody, request.Properties) ;
				Assert.IsTrue(resultantRtf.Contains("{\\rtf1"), "Mismatch in Property - body is not in RTF format");
				Assert.IsTrue(resultantRtf.Contains(rtfBody), "Mismatch in Property - RTF body does not contain the correct body text");

				Assert.AreEqual(subject, GetPropertyValue(MailMessagePropertyKeys.Subject,request.Properties ), "Mismatch in Property");
				Assert.AreEqual("Outlook", GetPropertyValue(SMTPPropertyKeys.RequestChannel, request.Properties), "Mismatch in Property");
				Assert.AreEqual("test.doc ", GetPropertyValue(MailMessagePropertyKeys.Attachments, request.Properties), "Mismatch in Property");

				Assert.AreEqual( GetPropertyValue(MailMessagePropertyKeys.xPriority, request.Properties ), "5");
			}
		}
        private void CreateProxy(Outlook.OlBodyFormat bodyFormat, out string proxyBodyText)
        {
            using (WsActivationContext wsac = new WsActivationContext())
            using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession))
            {
                string subject = "Test outlook proxy: This is a test mail";
                outlookEmailWrapper.Subject = subject;
                outlookEmailWrapper.ToRecipients = "*****@*****.**";
                outlookEmailWrapper.CcRecipients = "*****@*****.**";
                outlookEmailWrapper.BccRecipients = "[email protected];[email protected]";
                outlookEmailWrapper.BodyFormat = bodyFormat;
                outlookEmailWrapper.Body = "We have a body that looks like something";
                outlookEmailWrapper.AddAttachment(m_testPath + "test.doc", "Mickey Mouse", Outlook.OlAttachmentType.olByValue);
                outlookEmailWrapper.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;

                // We have to save the message in order to access all its contents :(
                outlookEmailWrapper.MailItem.Save();

                using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem))
                {
                    Assert.AreEqual("Test outlook proxy: This is a test mail", proxy.Subject);
                    Assert.IsTrue(proxy.FormattedBodyText.Contains("We have a body that looks like something"));
                    proxyBodyText = proxy.FormattedBodyText;

					if (Environment.UserName == "lnpair")
					{
	                    Assert.AreEqual("lnpair", proxy.Sender.Name);
	                    Assert.AreEqual("*****@*****.**", proxy.Sender.EmailAddress);
	                    Assert.IsTrue(proxy.Sender.Internal);
					}

                    Assert.IsTrue(proxy.ToRecipients.IsReadOnly);
                    Assert.IsTrue(proxy.CcRecipients.IsReadOnly);
                    Assert.IsTrue(proxy.BccRecipients.IsReadOnly);
                    
                    Assert.AreEqual(1, proxy.ToRecipients.Count);
                    Assert.AreEqual(1, proxy.CcRecipients.Count);
                    Assert.AreEqual(2, proxy.BccRecipients.Count);

					Assert.AreEqual("*****@*****.**", proxy.ToRecipients[0].Name.Trim('\''));
                    Assert.AreEqual("*****@*****.**", proxy.ToRecipients[0].EmailAddress);
					if (Environment.UserName == "lnpair")
					{
	                    Assert.IsFalse(proxy.ToRecipients[0].Internal);
					}

					Assert.AreEqual("*****@*****.**", proxy.CcRecipients[0].Name.Trim('\''));
                    Assert.AreEqual("*****@*****.**", proxy.CcRecipients[0].EmailAddress);
					if (Environment.UserName == "lnpair")
					{
	                    Assert.IsFalse(proxy.CcRecipients[0].Internal);
					}

					Assert.AreEqual("*****@*****.**", proxy.BccRecipients[0].Name.Trim('\''));
                    Assert.AreEqual("*****@*****.**", proxy.BccRecipients[0].EmailAddress);
					Assert.AreEqual("*****@*****.**", proxy.BccRecipients[1].Name.Trim('\''));
                    Assert.AreEqual("*****@*****.**", proxy.BccRecipients[1].EmailAddress);
					if (Environment.UserName == "lnpair")
					{
	                    Assert.IsFalse(proxy.BccRecipients[1].Internal);
					}

                    Assert.AreEqual(Workshare.Mime.Conversions.Priority.High, proxy.Priority);

                    // Lets test the recipient iterator as well
                    foreach (IEmailRecipient recipient in proxy.ToRecipients)
                    {
                        Assert.IsTrue(recipient.Name.Contains("blackhole"));
                    }

                    Assert.AreEqual(1, proxy.Attachments.Count);
                    // DE9310, requires to change this test behavior
					Assert.AreEqual("Mickey Mouse", proxy.Attachments[0].DisplayName);
					Assert.AreEqual("application/msword; name=Mickey Mouse", proxy.Attachments[0].ContentType);
                    Assert.IsTrue(proxy.Attachments[0].FileName.Contains("test.doc"), "Expected to find a non-empty stream");

                    // Lets test the attachment iterator as well
                    foreach (IEmailAttachment attachment in proxy.Attachments)
                    {
                        // DE9310, requires to change this test behavior
						Assert.IsTrue(attachment.DisplayName.Contains("Mickey Mouse"));
                        Assert.IsTrue(attachment.FileName.Contains("test.doc"));
                    }

                    outlookEmailWrapper.MailItem.Delete();
                }
            }
        }