Esempio n. 1
0
        public void TestEmbededImages()
        {
            // This test must be visually checked, meaning you have to check the output yourself
            msg.AddImage(@"..\lib\test attachments\test.jpg", "testimage");
            msg.AddImage(@"..\lib\test attachments\test2.jpg", "testimage2");
            msg.HtmlBody = "<body><table><tr><td><b>Here is an embedded IMAGE:<img src=\"cid:testimage\"></td></tr>\r\n<tr><td>Here's another: <img src=\"cid:testimage2\"></td></tr></table></body>";

            msg.Save(@"..\logs\testSaveEmbeded.eml");
        }
Esempio n. 2
0
        public void TestSend()
        {
            try
            {
                Console.WriteLine("\r\n ----- Smtp Test Below -----");

                msg.Subject = subject;
                msg.Body    = body;
                msg.AddImage(@"..\lib\test attachments\test.jpg", "testimage");
                msg.AddImage(@"..\lib\test attachments\test2.jpg", "testimage2");
                msg.HtmlBody = "<body><table><tr><td><b>Here is an embedded IMAGE:<img src=\"cid:testimage\"></td></tr>\r\n<tr><td>Here's another: <img src=\"cid:testimage2\"></td></tr></table></body>";


                msg.AddRecipient(ccAddress, AddressType.Cc);
                msg.AddRecipient(bccAddress, AddressType.Bcc);

                msg.AddAttachment(@"..\lib\test attachments\test.jpg");
                msg.AddAttachment(new Attachment(new FileStream(@"..\lib\test attachments\test.htm", FileMode.Open, FileAccess.Read), "test.htm"));

                msg.AddCustomHeader("X-FakeTestHeader", "Fake Value");
                msg.AddCustomHeader("X-AnotherFakeTestHeader", "Fake Value");
                msg.Notification = true;
                msg.Charset      = "ISO-8859-1";
                msg.Priority     = MailPriority.Low;


                smtp.Username = "******";
                smtp.Password = "******";


                for (int i = 0; i < 1; i++)
                {
                    smtp.SendMail(msg);
                }
            }
            catch (SmtpException se)
            {
                Assertion.Fail("TestSend() threw a SmtpException: " + se.Message);
            }
            catch (System.Exception e)
            {
                Assertion.Fail("TestSend() threw a System.Exception: " + e.Message + "; Target: " + e.TargetSite);
            }
        }