Пример #1
0
        /// <summary>
        /// Sends email with related  user inforamtion when users the install the application.
        /// Emails are sent to event email subceribers set in the settings.
        /// </summary>
        /// <param name="user">The user <see cref="AppUser"/>.</param>
        /// <returns></returns>
        public async Task <bool> UserInstalledAppAsync(AppUser user)
        {
            try
            {
                string msg = $"Hi <br/>";
                msg += $"{user.MyShopifyDomain} just <b style='color:green'>installed</b> the application. A welcome email has already been dispatched to the user.";
                msg += "<br/> Thanks <hr/>";
                msg += GetCurrentContextInHtml(user);
                _Emailer.SetMessage(msg, true);
                _Emailer.SetFromAddress(_Settings.GetShopifyFromEmailAddress());
                _Emailer.AddTo(_Settings.GetShopifyEmailSubscriberList());
                _Emailer.SetSubject($"💓 Installation | {_Settings.GetAppName()} | {user.MyShopifyDomain}");
                var result = await _Emailer.Send(true);

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