public ResponseModel SendQuery(EmailConfiguration emailConfiguration, SendQueryModel sendQueryModel)
        {
            ResponseModel responseModel = new ResponseModel();

            try
            {
                EmailSender _emailSender = new EmailSender(emailConfiguration);
                var         temp         = System.IO.File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "emailTemplate", "userquery.html"));
                temp = temp.Replace("##name##", sendQueryModel.Name)
                       .Replace("##query##", sendQueryModel.Query)
                       .Replace("##email##", sendQueryModel.Email)
                       .Replace("##mobile##", sendQueryModel.Phone)
                       .Replace("##question##", sendQueryModel.Question);
                var message = new Message(new string[] { "*****@*****.**", "*****@*****.**" }, "User Query - Bhashkar Jyotish Kendra", temp);
                _emailSender.SendEmail(message);
                responseModel.Msg  = "sent";
                responseModel.Code = HttpStatusCode.OK;
            }
            catch (Exception ex)
            {
                responseModel.Msg  = "notsent " + ex.Message + Path.Combine(Directory.GetCurrentDirectory());
                responseModel.Code = HttpStatusCode.InternalServerError;
            }
            return(responseModel);
        }
Exemplo n.º 2
0
        public string SendQuery(SendQueryModel sendQueryModel)
        {
            EmailServiceDetails emailServiceDetails = new EmailServiceDetails();
            EmailMessage        emailMessage        = new EmailMessage();
            var emailTemplate = emailServiceDetails.GetEmailTemplate(EmailTemplate.UserQuery);

            emailMessage.ToAddresses = emailServiceDetails.GetEmailsByGroup(EmailGroup.UserQuery);
            if (emailTemplate != null && sendQueryModel != null)
            {
                try
                {
                    emailMessage.Subject = emailTemplate.Subject.Replace("#AppName#", sendQueryModel.AppName);
                    emailMessage.Content = emailTemplate.Template;
                    emailMessage.Content = emailMessage.Content.Replace("#Body#", sendQueryModel.Query);
                    emailMessage.Content = emailMessage.Content.Replace("#AppName#", sendQueryModel.AppName);
                    emailMessage.Content = emailMessage.Content.Replace("#Name#", sendQueryModel.Name);
                    emailMessage.Content = emailMessage.Content.Replace("#Mobile#", sendQueryModel.Mobile);
                    emailMessage.Content = emailMessage.Content.Replace("#Email#", sendQueryModel.Email);

                    List <KeyValuePair <string, object> > param = new List <KeyValuePair <string, object> >()
                    {
                        new KeyValuePair <string, object>("@Name", sendQueryModel.Name),
                        new KeyValuePair <string, object>("@Query", sendQueryModel.Query),
                        new KeyValuePair <string, object>("@Mobile", sendQueryModel.Mobile),
                        new KeyValuePair <string, object>("@Email", sendQueryModel.Email)
                    };
                    var data = DataExecutor.ExecuteNonQuery(UtilityConstant.Procedures.Mst_SaveUserQuery, param);

                    Thread sendmail = new Thread(() => { emailServiceDetails.Send(emailMessage); });
                    sendmail.Start();
                }
                catch (Exception ex)
                {
                    return(UtilityConstant.UserResponseStatus.Error);
                }
            }
            return("EmailSend");
        }
 public JsonResult SendQuery([FromBody] SendQueryModel sendQueryModel)
 {
     return(Json(indexDetails.SendQuery(_emailConfiguration, sendQueryModel)));
 }