Exemplo n.º 1
0
        public virtual async Task SendAsync(MailModel mailModel)
        {
            if (mailModel == null)
            {
                throw new ArgumentNullException(nameof(mailModel));
            }

            var view = _viewPicker.GetView(mailModel.ViewName);

            if (string.IsNullOrEmpty(mailModel.MailMessage.Body))
            {
                mailModel.MailMessage.Body = await _renderingProvider.RenderAsync(view, mailModel.BaseModel);
            }

            await _mailClient.SendEmailAsync(mailModel.MailMessage);
        }
Exemplo n.º 2
0
        public async Task <bool> SendMessage(string userEmail, string userName, string message)
        {
            var result = false;

            try
            {
                var model = new
                {
                    UserEmail   = userEmail,
                    UserMessage = message,
                    UserName    = userName
                };

                var serverPath = HttpContext.Current.Server.MapPath(contactMessagePath);
                var template   = File.ReadAllText(serverPath);
                var body       = Engine.Razor.RunCompile(template, DateTime.UtcNow.Ticks.ToString(), null, model);
                var subject    = "Contact Message";
                result = await mailClient.SendEmailAsync(ConfigurationManager.AppSettings["adminEmail"], subject, body);
            }
            catch (Exception e)
            {
                throw new NotImplementedException();
            }
            return(result);
        }