Exemple #1
0
        /// <summary>
        /// Sends the support email to the app admin.
        /// Emails are sent to support emails defined in the settings.
        /// </summary>
        /// <param name="user">The user <see cref="AppUser"/></param>
        /// <param name="model"><see cref="ContactUsViewModel"/></param>
        /// <returns></returns>
        public async Task <bool> SendSupportEmailAsync(AppUser user, ContactUsViewModel model)
        {
            try
            {
                string msg = model.Message.Replace("\r\n", "<br/>") + "<br/><hr/>" + GetCurrentContextInHtml(user);
                _Emailer.AddTo(_Settings.GetAppSupportEmailAddress());
                _Emailer.SetFromAddress(_Settings.GetShopifyFromEmailAddress());
                var _msg = $"<h3>{model.Name} wrote</h3><br/><hr/>{msg}<br/><hr>";
                _Emailer.SetMessage(_msg, true);
                _Emailer.SetSubject($"☎ {model.Subject} | {model.ShopDomain} | {model.Name}");
                var result = await _Emailer.Send(true);

                if (result)
                {
                    _Logger.LogInformation("Sending user support email was successful.");
                }
                else
                {
                    _Logger.LogInformation("Sending user support email was unsuccessful.");
                }
                return(result);
            }
            catch (Exception ex)
            {
                _Logger.LogError(ex, $"Error sending support email.{ex.Message}");
                return(false);
            }
        }