예제 #1
0
        public JsonResult Index(Models.Email model)
        {
            MailMessage mailim = new MailMessage();

            mailim.To.Add("*****@*****.**");
            mailim.From       = new MailAddress("*****@*****.**");
            mailim.Subject    = "Bize Ulaşın Sayfasından Mesajınız Var. ";
            mailim.Body       = "Ad soyad:" + model.ad + " <br> Mail adresim:" + " " + model.email + " <br>Telefon Numaram:" + model.telefon + " <br>Konu:" + model.konu + " <br>Mesaj:" + model.mesaj;
            mailim.IsBodyHtml = true;



            SmtpClient smtp = new SmtpClient();

            smtp.Credentials = new NetworkCredential("*****@*****.**", "uyN_R:F3Wo2m24_:");
            smtp.Port        = 587;
            smtp.Host        = "smtp.benimfatura.com";
            smtp.EnableSsl   = false;


            try
            {
                smtp.Send(mailim);
            }
            catch (Exception)
            {
            }


            return(Json("asdasd"));
        }
예제 #2
0
        public void Send(Models.Email message)
        {
            var mailMessage = new MailMessage
            {
                Subject    = message.Subject,
                IsBodyHtml = message.IsBodyHtml,
                Priority   = message.Priority,
                Body       = message.Body,
                From       = new MailAddress(message.From)
            };

            foreach (var to in message.To.Split(';'))
            {
                mailMessage.To.Add(to.Trim());
            }

            if (!string.IsNullOrWhiteSpace(message.CC))
            {
                foreach (var cc in message.CC.Split(';'))
                {
                    mailMessage.CC.Add(cc.Trim());
                }
            }

            _client.Send(mailMessage);
        }
예제 #3
0
        // De emailtemplate.html file path moet gegeven worden, zet dit naar eigen PC of DEBUG
        public static bool SendEmailNew(Models.Email email, string activatiehash, string voornaam)
        {
            string emailaangepast = System.IO.File.ReadAllText(HttpRuntime.AppDomainAppPath + "/Email/emailtemplate.html");

            //veranderd de info in de template
            emailaangepast = emailaangepast.Replace("#activatiehash#", activatiehash);
            emailaangepast = emailaangepast.Replace("#voornaam#", voornaam);
            using (SmtpClient client = Emailserver.Client)
            {
                try
                {
                    MailMessage mm = new MailMessage("*****@*****.**", email.Ontvanger, email.Onderwerp, emailaangepast);
                    mm.IsBodyHtml   = true;
                    mm.BodyEncoding = UTF8Encoding.UTF8;
                    mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

                    client.Send(mm);
                    return(true);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
        }
예제 #4
0
        public void sendEmail(int departmentHeadBadgeNumber, string subject, string travelRequestId, string requestType, string fileAttachment)
        {
            try
            {
                var emailAndFirstName = getEmailAddressByBadgeNumber(departmentHeadBadgeNumber);
                var email             = new Models.Email()
                {
                    FromAddress = ConfigurationManager.AppSettings["TravelApplicationEmailId"],
                    ToAddress   = emailAndFirstName[0],
                    Body        = GetApprovalRequestEmailBody(emailAndFirstName[1], travelRequestId, departmentHeadBadgeNumber, requestType),
                    Subject     = subject
                };
                //Generate Crystal report
                string fileName = System.Web.Hosting.HostingEnvironment.MapPath(@"~/Reports/Exported/" + fileAttachment + ".pdf");

                // email with attachment
                emailService.SendEmail(email.FromAddress, email.ToAddress, email.Subject, email.Body, fileName, "", "", "").ConfigureAwait(false);

                //Once emailed delete the attached file
                //System.IO.File.Delete(fileName);
            }
            catch (Exception ex)
            {
                LogMessage.Log("Email send failed : " + ex.Message);
                throw new Exception("Email failed : " + ex.Message);
            }
        }
예제 #5
0
        /// <summary>
        ///     Sorts email addresses by type.  Order is Primary, Secondary, Other, Kaplan.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <returns></returns>
        public static int SortEmailAddressesByType(Models.Email x, Models.Email y)
        {
            string emailTypeX = x.EmailType.ToUpperInvariant();
            string emailTypeY = y.EmailType.ToUpperInvariant();

            if (string.Compare(emailTypeX, emailTypeY, StringComparison.Ordinal) == 0)
            {
                return(0);
            }

            if (emailTypeX == EMAILTYPE_PRIMARY)
            {
                return(-1);
            }
            if (emailTypeX == EMAILTYPE_KAPLAN)
            {
                return(1);
            }
            if (emailTypeX == EMAILTYPE_SECONDARY)
            {
                if (emailTypeY == EMAILTYPE_PRIMARY)
                {
                    return(1);
                }
                else
                {
                    return(-1);
                }
            }

            return(0);
        }
 public Models.Email_DTO Get(string email)
 {
     //make internal email object.
     Models.Email emailObject = new Models.Email(email);
     //Check email
     emailObject.valid = EmailValidator.IsValidEmail(emailObject.email);
     //store in DTO and return.
     Models.Email_DTO edto = new Models.Email_DTO(emailObject);
     return(edto);
 }
예제 #7
0
 private static email_addresses ToEmailAddressEntity(this Models.Email email)
 {
     return(new email_addresses
     {
         id = email.Id,
         email_address = email.EmailAddress,
         is_primary = email.IsPrimary,
         is_verified = email.IsVerified
     });
 }
예제 #8
0
        public async Task <IActionResult> SendEmail(Models.Email email)
        {
            var response = await Helpers.Email.Send(email.From, email.To, email.Subject, email.PlainTextContent, email.HtmlContent, email.AttachementName, email.AttachementContent);

            var body = await response.Body.ReadAsStringAsync();

            return(new ContentResult()
            {
                Content = body, StatusCode = (int)response.StatusCode
            });
        }
        public string SendEmail(Models.Email email)
        {
            var isValidEmail = _emailsValidation.IsEmailAddressValid(email.EmailAddress);

            if (isValidEmail.isValid)
            {
                _smtpClient.Send("*****@*****.**", _environmentConfig.FFSA, "NAME: " + email.Name + " Email: " + email.EmailAddress, email.Message);
                return(isValidEmail.message);
            }

            return(isValidEmail.message);
        }
예제 #10
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var mail = new Models.Email
            {
                Address    = email,
                Subject    = subject,
                Message    = message,
                CreateDate = DateTimeService.SfuServerNow,
            };

            _repository.Add(mail);
            await _repository.SaveChangesAsync();
        }
예제 #11
0
        public string SendEmail(Models.Email email)
        {
            var isValidEmail = _emailsValidation.IsEmailAddressValid(email.FromEmail);

            if (isValidEmail.isValid)
            {
                SmtpClient _smtpClient = _emailhelper.smtpClient(email.FromEmail, email.EmailPassword, email.Host, email.Port);
                _smtpClient.Send(email.FromEmail, email.ToEmail, email.Subject, email.Body);
                return(isValidEmail.message);
            }

            return(isValidEmail.message);
        }
        public void constructEmailBody(Models.Email email)
        {
            var message = new StringBuilder();

            message.Append("Hi Team" + "\n\n");
            message.Append("This is a confirmation email that we have recieved your application for course:");

            message.Append("The team wiil be in touch with you soon." + "\n\n");

            message.Append("Kind Regards" + "\n" + "Client Support");

            //return message.ToString();
        }
예제 #13
0
        public List <Models.Contato> InicializeObject()
        {
            int j = 0;
            List <Models.Contato> contatos = new List <Models.Contato>();

            for (int i = 0; i < 10; i++)
            {
                var contato = new Models.Contato()
                {
                    IdContato = i,
                    Nome      = string.Format("Contato_{0}", i),
                };

                var email = new Models.Email()
                {
                    IdEmail      = j,
                    EmailAddress = string.Format("email_{0}@teste.com.br", j)
                };
                var email2 = new Models.Email()
                {
                    IdEmail      = j + 1,
                    EmailAddress = string.Format("email_{0}@teste.com.br", j + 1)
                };

                var telefone = new Models.Telefone()
                {
                    IdTelefone = j,
                    Numero     = string.Format("({0}{1})12345-6789", j, j)
                };

                var telefone2 = new Models.Telefone()
                {
                    IdTelefone = j + 1,
                    Numero     = string.Format("({0}{1})12345-6789", j + 1, j + 1)
                };

                j++;
                contato.Emails.Add(email);
                contato.Emails.Add(email2);

                contato.Telefones.Add(telefone);
                contato.Telefones.Add(telefone2);

                contatos.Add(contato);
            }

            return(contatos);
        }
예제 #14
0
        public async Task <Models.Email> UpdateAsync(Guid parentId, Models.Email entity)
        {
            var builder = Builders <Models.Contact> .Filter;
            var filter  = builder.Eq(x => x.Id, parentId)
                          & builder.ElemMatch(x => x.Emails, it => it.Id == entity.Id);
            var update = Builders <Models.Contact> .Update
                         .Set(x => x.Emails[-1], entity);

            var result = await _context.Contacts.UpdateOneAsync(filter, update);

            if (result.ModifiedCount != 1)
            {
                throw new ClientFriendlyException($"record update failed {parentId}");
            }
            return(entity);
        }
예제 #15
0
        public async Task <Models.Email> CreateAsync(Guid parentId, Models.Email entity)
        {
            entity.Id = Guid.NewGuid();
            var filter = Builders <Models.Contact> .Filter.Eq(x => x.Id, parentId);

            var update = Builders <Models.Contact> .Update
                         .AddToSet(x => x.Emails, entity);

            var result = await _context.Contacts.UpdateOneAsync(filter, update);

            if (result.ModifiedCount != 1)
            {
                throw new ClientFriendlyException($"record creation failed {parentId}");
            }
            return(entity);
        }
예제 #16
0
        public bool SendEmail(Models.Email info, string subject, string body)
        {
            var    to        = info.To;
            var    from      = info.From;
            var    password  = info.Password;
            var    smtpPort  = info.SMTPPort;
            var    enableSSL = info.EnableSSL;
            string Subject   = GeneralFuncs.GetEmailFormatByKey("Subject");
            string Body      = GeneralFuncs.GetEmailFormatByKey("Body");

            Body    = Body.Replace("[content]", body);
            Subject = Subject.Replace("[content]", subject);

            T.Core.Common.Email.SendMail(from, to, from, password, smtpPort, enableSSL, Subject, Body);
            return(true);
        }
예제 #17
0
        public HttpResponseMessage Email(Models.Email email)
        {
            HttpResponseMessage response = null;

            try
            {
                var result = emailService.SendEmail(email.FromAddress, email.ToAddress, email.Subject, email.Body).ConfigureAwait(false);
                response = Request.CreateResponse(HttpStatusCode.OK, result);
            }
            catch (Exception ex)
            {
                LogMessage.Log("api/email/sendemail : " + ex.Message);
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Could not send an email.");
            }

            return(response);
        }
예제 #18
0
        public IActionResult Post([FromBody] Models.Email_DTO email_dto)
        {
            var  email      = new Models.Email(email_dto);
            bool emailValid = EmailValidator_Gateway.ValidateEmail(email.Address).valid;

            if (emailValid)                               //send email.
            {
                var q  = QuoteFetcher_Gateway.GetQuote(); //response.Data;
                var wp = WikipediaFetcher_Gateway.GetWikipediaPage(q.author);
                EmailSender.SendEmailWithSmtp(email, q, wp);
                return(Json("Email sent to " + email_dto.address));
            }
            else //give error message.
            {
                return(Json("Could not validate email: " + email_dto.address));
            }
        }
예제 #19
0
        private void SendEmailButtonClicked(object sender, RoutedEventArgs e)
        {
            Models.Email email = new Models.Email();
            email.email = MemberATE.email;
            RestClient client = new RestClient(urlBase);

            client.Timeout = -1;
            var request = new RestRequest("emails", Method.POST);
            var json    = JsonConvert.SerializeObject(email);

            request.AddParameter("application/json", json, ParameterType.RequestBody);
            System.Net.ServicePointManager.ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => { return(true); };
            try
            {
                IRestResponse response = client.Execute(request);
                if (response.StatusCode == System.Net.HttpStatusCode.Created || response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    MessageBox.Show("El código de confirmación se envio exitosamente", "Envío exitoso", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    Models.Error responseError = JsonConvert.DeserializeObject <Models.Error>(response.Content);
                    MessageBox.Show(responseError.error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    if (response.StatusCode != System.Net.HttpStatusCode.Conflict && response.StatusCode != System.Net.HttpStatusCode.BadRequest &&
                        response.StatusCode != System.Net.HttpStatusCode.NotFound)
                    {
                        Login login = new Login();
                        login.Show();
                        Close();
                    }
                }
            }
            catch (Exception exception)
            {
                TelegramBot.SendToTelegram(exception);
                LogException.Log(this, exception);
                MessageBox.Show("No se pudo enviar el codigo de confirmación. Intente más tarde", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Login login = new Login();
                login.Show();
                Close();
            }
        }
        public ActionResult Create(FormCollection collection)
        {
            Account account = new Account(collection["Voornaam"], collection["Tussenvoegsel"], collection["Achternaam"], Convert.ToInt32(collection["Telefoonnummer"]), collection["Gebruikersnaam"], collection["Wachtwoord"], collection["Email"], MD5.CreateMD5(collection["Email"]), 0);

            try
            {
                // TODO: Add insert logic here
                accountrepo.InsertAccount(account);
                Models.Email mail = new Models.Email("Activeer uw account", "inhoud", "*****@*****.**");
                //EmailLogic.SendEmail(mail);
                EmailLogic.SendEmailNew(mail, account.Activatiehash, account.Voornaam);

                return(RedirectToAction("Create", "Account"));
            }
            catch
            {
                throw;
                //return View();
            }
        }
예제 #21
0
        public void sendNewReimbursementRequestEmail(int travelRequestBadgeNumber, string subject, string travelRequestId)
        {
            try
            {
                var emailAndFirstName = getEmailAddressByBadgeNumber(travelRequestBadgeNumber);
                var email             = new Models.Email()
                {
                    FromAddress = ConfigurationManager.AppSettings["TravelApplicationEmailId"],
                    ToAddress   = emailAndFirstName[0],
                    Body        = GetNewReimbursementRequestEmailBody(emailAndFirstName[1], travelRequestId),
                    Subject     = subject
                };

                emailService.SendEmail(email.FromAddress, email.ToAddress, email.Subject, email.Body).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                LogMessage.Log("Email send failed : " + ex.Message);
                throw new Exception("Email failed : " + ex.Message);
            }
        }
예제 #22
0
        public static bool SendEmail(Models.Email email)
        {
            using (SmtpClient client = Emailserver.Client)
            {
                try
                {
                    MailMessage mm = new MailMessage("*****@*****.**", email.Ontvanger, email.Onderwerp, email.Inhoud);
                    mm.IsBodyHtml   = true;
                    mm.BodyEncoding = UTF8Encoding.UTF8;
                    mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

                    client.Send(mm);
                    return(true);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
        }
예제 #23
0
        public void sendRejectionEmail(int badgeNumber, string subject, string travelRequestId, string comments, string rejectReason)
        {
            try
            {
                string link = string.Format("<a href=\"http://localhost:2462/\">here</a>");
                var    emailAndFirstName = getEmailAddressByBadgeNumber(badgeNumber);

                var email = new Models.Email()
                {
                    FromAddress = ConfigurationManager.AppSettings["TravelApplicationEmailId"],
                    ToAddress   = emailAndFirstName[0],
                    Body        = GetRejectionRequestEmailBody(emailAndFirstName[1], travelRequestId, comments, rejectReason),
                    Subject     = subject
                };

                emailService.SendEmail(email.FromAddress, email.ToAddress, email.Subject, email.Body).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                LogMessage.Log("Rejections email failed : " + ex.Message);
                throw new Exception(ex.Message);
            }
        }
예제 #24
0
        public async Task <IActionResult> Email([Bind("EmailId,EmailStr")] Models.Email emailMod, string email)
        {
            if (ModelState.IsValid)
            {
                if (email != null)
                {
                    var count = _context.Steps_Emails
                                .Where(s => s.EmailStr.Equals(email.ToString()))
                                .Select(o => o.EmailId)
                                .Count();

                    if (count == 0)
                    {
                        Models.Email emailNew = new Models.Email
                        {
                            EmailId  = emailMod.EmailId,
                            EmailStr = email
                        };
                        _context.Add(emailNew);
                        await _context.SaveChangesAsync();

                        ViewBag.State        = "Success!";
                        ViewBag.StateMessage = "Your e-mail has successfully been added. Check your inbox!";
                        return(View());
                    }
                    else
                    {
                        ViewBag.State        = "Hmm, something went wrong...";
                        ViewBag.StateMessage = "You need to enter a valid email that isn't already on the list. Try again!";
                        return(View());
                    }
                }
            }
            ViewBag.State        = "Hmm, something went wrong...";
            ViewBag.StateMessage = "You need to enter a valid email that isn't already on the list. Try again!";
            return(View());
        }
예제 #25
0
        public void constructEmailBody(Models.Email email)
        {
            var message = new StringBuilder();

            message.Append(email.Body);
        }
예제 #26
0
        public void TestAgainstDatabase()
        {
            //---------------Set up test pack-------------------
            using (var db = new TempDB())
            {
                var ctx = new EmailContext(db.CreateConnection());
                //---------------Assert Precondition----------------

                //---------------Execute Test ----------------------
                var email = new Models.Email
                {
                    Subject = RandomValueGen.GetRandomString(),
                    Sender = RandomValueGen.GetRandomString(),
                    Body = RandomValueGen.GetRandomString(),
                    SendAt = DateTime.Now
                };

                var recipient = new Models.EmailRecipient
                {
                    Recipient = "*****@*****.**"
                };
                email.EmailRecipients.Add(recipient);

                var attachment = new Models.EmailAttachment
                {
                    Data = RandomValueGen.GetRandomBytes(),
                    MIMEType = "application/octet-stream",
                    Name = "sneaky.file",
                    ContentID = Guid.NewGuid().ToString()
                };

                email.EmailAttachments.Add(attachment);

                ctx.Emails.Add(email);

                try
                {
                    ctx.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    var message = String.Join("\n\n", ex.EntityValidationErrors.Select(e =>
                        String.Join("\n", e.ValidationErrors.Select(ve => ve.ErrorMessage))));
                    throw new Exception(message);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    throw;
                }

                CollectionAssert.IsNotEmpty(ctx.Emails);

                var ctx2 = new EmailContext(db.CreateConnection());
                var email2 = ctx.Emails.FirstOrDefault();
                Assert.IsNotNull(email2);
                PropertyAssert.AllPropertiesAreEqual(email, email2);
                //---------------Test Result -----------------------
            }
        }
예제 #27
0
 public EmailSavedEvent(Models.Email email)
     : base(EventTypes.Success)
 {
     Email       = email;
     AggregateId = email.Type.ToString();
 }
예제 #28
0
 public MailManager(SmtpClient smtp, IOptions <Configuracoes> configuracoes)
 {
     _smtp          = smtp;
     _configuracoes = configuracoes;
     _emailPadrao   = _configuracoes.Value.Email;
 }
 public string SendEmail(Models.Email email)
 {
     return(_emailService.SendEmail(email));
 }
 public EmailSavedEvent(Models.Email email)
     : base(EventTypes.Success)
 {
 }