Esempio n. 1
0
        public Task SendEmailAsync(string email, EmailTemplateEnum mailType, Dictionary <string, string> paramsDict)
        {
            if (!_disabled)
            {
                email = _isDev ? _devEmail : email;
                var message    = EmailTemplateHelper.ReadTemplate(mailType);
                var subject    = EmailTemplateHelper.ReadSubject(mailType);
                var attachment = EmailTemplateHelper.ReadAttachment(mailType);
                foreach (var param in paramsDict)
                {
                    message = message.Replace("{{" + param.Key + "}}", param.Value);
                    subject = subject.Replace("{{" + param.Key + "}}", param.Value);
                }
                //todo Remove this crutch
                if (_isDev)
                {
                    message = message.Replace("http://localhost:8080/img/vshopelogosmall.png",
                                              "https://freshopdev.azurewebsites.net/img/vshopelogosmall.png");
                }
                return(Execute(_config["Sendgrid:Key"], subject, message, email, attachment));
            }

            return(Task.CompletedTask);
        }