private static Email Map(EMailHtmlForsendelseDTO request)
 {
     EmailUser sender = Map(request.Sender);
     Email mail = new Email(sender);
     mail.To.AddRange(Map(request.To));
     mail.Cc.AddRange(Map(request.Cc));
     mail.Bcc.AddRange(Map(request.Bcc));
     mail.Subject = request.Subject;
     mail.Body = Map(request.Body);
     mail.Attachments.AddRange(Map(request.Attachments));
     return mail;
 }
        public void SendEMailTest()
        {
            UnitTestHelper.InitierAlleKomponenterMedDefault();
            SmtpGatewayEMailDistributoer eMailDistributoer = new SmtpGatewayEMailDistributoer();
            LoggingManagerUnitTest loggingManager = new LoggingManagerUnitTest();
            KomponentManager.EMailDistributoer = eMailDistributoer;
            KomponentManager.LoggingManager = loggingManager;

            EMailHtmlBodyIndlejretBilledeDTO indlejretBillede = HentIndlejretBillede(Directory.GetCurrentDirectory() + @"\Billeder\smileyOne.jpg");
            EMailAttachmentDTO attachmentBillede = HentAttachmentBillede(Directory.GetCurrentDirectory() + @"\Billeder\smileyTwo.jpg");
            EMailBrugerDTO brugerThomasDalsgaard = new EMailBrugerDTO();
            brugerThomasDalsgaard.EMailAdresse = "*****@*****.**";
            brugerThomasDalsgaard.Navn = "Thomas Dalsgaard";
            string subject = "Smil!!!";
            EMailHtmlBodyDTO body = new EMailHtmlBodyDTO();
            body.IndlejretBilleder.Add(indlejretBillede);
            body.BodyTekst =
                "<html><body>" +
                "<h1>Smil og vær glad ;)</h1>" +
                "<p>Vær ikke genert!</p>" +
                "<img src=\"" + indlejretBillede.BilledeID +"\" alt=\"Smiley face\" height=\"42\" width=\"42\">" +
                "<p>Se det er ikke så svært ^^</p>" +
                "</body></html>";

            EMailHtmlForsendelseDTO forsendelse = new EMailHtmlForsendelseDTO();
            forsendelse.Sender = brugerThomasDalsgaard;
            forsendelse.To.Add(brugerThomasDalsgaard);
            forsendelse.Subject = subject;
            forsendelse.Body = body;
            forsendelse.Attachments.Add(attachmentBillede);

            bool succes = false;
            try
            {
                eMailDistributoer.SendEMail(forsendelse);
                succes = true;
            }
            catch (Exception)
            {

            }
            string resultat = loggingManager.ToString();
            Assert.IsTrue(succes);
        }
 public void SendEMail(EMailHtmlForsendelseDTO eMailDefinition)
 {
     Email mail = Map(eMailDefinition);
     SmtpGateway smtpGateway = new SmtpGateway(_smtpGatewayForbindelse);
     smtpGateway.SmtpGatewayTimeoutInMiliseconds = _smtpGatewayTimeoutIMillisekunder;
     bool succeeded = smtpGateway.TrySend(mail);
     if (succeeded)
     {
         StringBuilder sb = new StringBuilder();
         sb.AppendLine("MAIL SENT");
         sb.AppendLine(mail.ToString());
         KomponentManager.LoggingManager.LogBesked(MAIL_SENDING_SUCCES, sb.ToString());
     }
     else
     {
         StringBuilder sb = new StringBuilder();
         sb.AppendLine("MAIL SENDING FAILED");
         sb.AppendLine(mail.ToString());
         sb.AppendLine("ERROR: " + mail.FailedByException.ToString());
         KomponentManager.LoggingManager.LogBesked(MAIL_SENDING_FAIL, sb.ToString());
     }
 }
 public void SendEMail(EMailHtmlForsendelseDTO eMailDefinition)
 {
     ForsoegtSendteMails.Add(eMailDefinition);
 }