Beispiel #1
0
        public async Task <IActionResult> Form([Bind(Prefix = "block.ContactForm")] ContactFormDTO contactForm)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    /*
                     * Email per l'owner del sito
                     */
                    await _mailer.SendEmailAsync(_configuration["ContactForm:ContactRequestEmail"], $"Richiesta di contatto ricevuta dal sito",
                                                 @$ "
Nuovo contatto ricevuto<br>
Nome: {contactForm.Name}<br>
Email: {contactForm.Email}<br>
Beispiel #2
0
        public JsonResult ContactForm(ContactFormDTO obj)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(ModelState));
                }

                SendMessage(obj);
                return(Json(new { status = "success", message = "We have received your message, shall contact you shortly." }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "error", message = "Unable to send message. " + ex.Message }));
            }
        }
Beispiel #3
0
        private void SendMessage(ContactFormDTO obj)
        {
            EmailMessage em = new EmailMessage();

            em.CCAddress   = string.Empty;
            em.CreateDate  = DateTime.Now;
            em.EmailGroup  = "ContactForm";
            em.EmailType   = EmailMessageType.Communication;
            em.FromAddress = obj.Email;
            em.FromName    = obj.Name;
            em.PublicID    = Guid.NewGuid();
            em.Message     = string.Format("Phone: {0} <br/>Email: {1} <br/> Website: {2} <br/> Purpose:<br />{4} <br/> Message:<br/> {3}",
                                           obj.Phone, obj.Email, obj.Website, obj.Message, obj.Purpose);
            em.Subject   = string.Format("Message From {0}", obj.Name);
            em.ToAddress = Utility.NewsletterEmail;
            em.ToName    = Utility.AdminName;
            EmailManager manager = new EmailManager(db);

            manager.AddMessage(em.PublicID, em.ToAddress, em.FromAddress, em.Subject, em.Message, em.EmailType, em.EmailGroup, em.CCAddress, em.ToName, em.FromName);
            manager.SendMail(em);
        }