private EmailMessage GetTestHtmlAndTextMessage() 
		{
			EmailMessage emailmessage=new EmailMessage();

			emailmessage.FromAddress=TestAddressHelper.GetFromAddress();
			emailmessage.AddToAddress(TestAddressHelper.GetToAddress());
			emailmessage.Subject="EmailMessageTests Test HTML and Text";
			emailmessage.TextPart=new TextAttachment("This\r\nis the\r\ntext\r\npart.");
			emailmessage.HtmlPart=new HtmlAttachment("<html><body>This<br>\r\nis the<br>\r\n<strong>HTML</strong><br>\r\npart.</body></html>");

			emailmessage.AddCustomHeader("X-MyHeader1", "my header number one");
			emailmessage.AddCustomHeader("X-MyHeader2", "my header number two");

			return emailmessage;
		}
		public void TestSend() 
		{
			EmailMessage emailmessage=new EmailMessage();

			emailmessage.FromAddress=TestAddressHelper.GetFromAddress();
			//emailmessage.FromAddress=new EmailAddress("*****@*****.**", "Bridge, Mike");
			//emailmessage.FromAddress=new EmailAddress("*****@*****.**", "<Mike Bridge>");

			emailmessage.AddToAddress(TestAddressHelper.GetToAddress());
			emailmessage.Subject="EmailMessageTests Test HTML and Text";
			emailmessage.TextPart=new TextAttachment("This\r\nis the\r\ntext\r\npart.");
			emailmessage.HtmlPart=new HtmlAttachment("<html><body>This<br>\r\nis the<br>\r\n<strong>HTML</strong><br>\r\npart.</body></html>");

			emailmessage.BodyText="This is a test";

			emailmessage.AddCustomHeader("X-MyHeader1", "my header number one");
			//emailmessage.AddCustomHeader("Sender", TestAddressHelper.GetToAddress().ToString());

			Log4netLogger logger=new Log4netLogger();
			_smtpserver.LogSmtpWrite+=(new SmtpServer.LogHandler(logger.Log));
			_smtpserver.LogSmtpReceive+=(new SmtpServer.LogHandler(logger.Log));
			_smtpserver.LogSmtpCompleted+=(new SmtpServer.LogHandler(logger.Log));
			
			emailmessage.Send(_smtpserver);

		

		}
		public void TestHtmlAndText() 
		{
			EmailMessage emailmessage=new EmailMessage();

			emailmessage.FromAddress=TestAddressHelper.GetFromAddress();
			emailmessage.AddToAddress(TestAddressHelper.GetToAddress());
			emailmessage.Subject="EmailMessageTests Test HTML and Text";
			emailmessage.TextPart=new TextAttachment("This\r\nis the\r\ntext\r\npart.");
			emailmessage.HtmlPart=new HtmlAttachment("<html><body>This<br>\r\nis the<br>\r\n<strong>HTML</strong><br>\r\npart.</body></html>");

			emailmessage.AddCustomHeader("X-MyHeader1", "my header number one");
			emailmessage.AddCustomHeader("X-MyHeader2", "my header number two");

			emailmessage.Send(_smtpserver);

			String content=emailmessage.ToDataString();
			StringReader sr=new StringReader(content);
			log.Debug(content);

			int i=0;
			String line=null;
			bool hasToHeader=false;
			bool hasFromHeader=false;
			bool hasSubjectHeader=false;
			bool hasMimeVersion=false;
			bool hasMultipartAlternative=false;
			bool hasPlainText=false;
			bool hasHtmlText=false;
			bool hasDefaultXMailerHeader=false;
			bool hasCustomHeader1=false;
			bool hasCustomHeader2=false;
			int quotedPrintableParts=0;

			String expectedToAddress=TestAddressHelper.GetToAddress().Name+" <"+TestAddressHelper.GetToAddress().Email+">";
			
			while ((line=sr.ReadLine())!=null) 
			{
				i++;
				if (line.IndexOf("To: "+expectedToAddress)==0) 
				{
					hasToHeader=true;
				}
				if (line.IndexOf("From: "+emailmessage.FromAddress.ToString())==0) 
				{
					hasFromHeader=true;
				}
				if (line.IndexOf("Subject: "+emailmessage.Subject)==0) 
				{
					hasSubjectHeader=true;
				}
				if (line.IndexOf("MIME-Version: 1.0")==0) 
				{
					hasMimeVersion=true;
				}
				if (line.IndexOf("Content-Type: multipart/alternative;")==0) 
				{
					hasMultipartAlternative=true;
				}
				if (line.IndexOf("Content-Type: text/html")==0) 
				{
					hasHtmlText=true;
				}
				if (line.IndexOf("Content-Type: text/plain")==0) 
				{
					hasPlainText=true;
				}
				if (line.IndexOf("Content-Transfer-Encoding: quoted-printable")==0) 
				{
					quotedPrintableParts++;
				}
				if (line.IndexOf("X-Mailer: DotNetOpenMail") == 0)
				{
					hasDefaultXMailerHeader=true;
				}
				if (line.IndexOf("X-MyHeader1: my header number one") == 0)
				{
					hasCustomHeader1=true;
				}
				if (line.IndexOf("X-MyHeader2: my header number two") == 0)
				{
					hasCustomHeader2=true;
				}

				// log.Debug("Line "+i+": "+line);				
			}
			Assert.IsTrue(hasToHeader, "Missing TO Header");
			Assert.IsTrue(hasFromHeader, "Missing FROM Header");
			Assert.IsTrue(hasSubjectHeader, "Missing Subject Header");
			Assert.IsTrue(hasMimeVersion, "Missing Mime Version header");
			Assert.IsTrue(hasMultipartAlternative, "Missing Mime Multipart/Alternative setting");
			Assert.IsTrue(hasPlainText, "Missing Plain Text");
			Assert.IsTrue(hasHtmlText, "Missing HTML");
			Assert.IsTrue(hasDefaultXMailerHeader, "Missing X-Mailer Header");
			Assert.IsTrue(hasCustomHeader1, "Missing Custom Header 1");
			Assert.IsTrue(hasCustomHeader2, "Missing Custom Header 2");
			Assert.AreEqual(2, quotedPrintableParts, "Expected 2 quoted printable declarations, found "+quotedPrintableParts);
		
			
		

		}
		public void TestExtraHeader() 
		{
			EmailMessage emailmessage=new EmailMessage();

			emailmessage.FromAddress=TestAddressHelper.GetFromAddress();
			emailmessage.AddToAddress(TestAddressHelper.GetToAddress());
			emailmessage.AddCcAddress(TestAddressHelper.GetToAddress());
			emailmessage.AddBccAddress(TestAddressHelper.GetToAddress());
			emailmessage.Subject="Extra Header";
			emailmessage.HeaderEncoding=DotNetOpenMail.Encoding.EncodingType.QuotedPrintable;
			emailmessage.XMailer="NUnit Test Mailer";
			emailmessage.AddCustomHeader("MyHeader", "Value");
			emailmessage.TextPart=new TextAttachment("This\r\nis the\r\ntext\r\npart.");
			emailmessage.HtmlPart=new HtmlAttachment("<html><body>This<br>\r\nis the<br>\r\n<strong>HTML</strong><br>\r\npart.</body></html>");

			String content=emailmessage.ToDataString();
			emailmessage.Send(_smtpserver);

		}