/// <summary>
        /// Adds the <c>IEmailSender</c> services to the specified <c>Microsoft.Extensions.DependencyInjection.IServiceCollection</c>.
        /// <c>EmailOptions</c> will be loaded from the the settings configuration,
        /// if any; otherwise, default <c>EmailOptions</c> will be used instead.
        /// </summary>
        /// <param name="services">The <c>Microsoft.Extensions.DependencyInjection.IServiceCollection</c> to add the service to.</param>
        /// <param name="settings">
        /// The settings used to bind configurations to the <c>EmailOptions</c>.
        /// Make sure the Configuration and EmailOptionsConfigurationKey property are set.
        /// </param>
        /// <returns>A reference to this instance after the operation has completed.</returns>
        public static IServiceCollection AddForEvolveEmailSender(this IServiceCollection services, ForEvolveAspNetCoreSettings settings)
        {
            var emailOptions = new EmailOptions();

            settings.Configuration?.Bind(settings.EmailOptionsConfigurationKey, emailOptions);
            return(services.AddForEvolveEmailSender(emailOptions));
        }
Exemplo n.º 2
0
        public async Task <bool> AddNewUser(UserInputViewModel userInputVm)
        {
            var user = new User {
                UserName = userInputVm.Username, Email = userInputVm.Email
            };
            var randomPassword = RandomString.GenerateRandomString();
            var result         = await _userService.CreateAsync(user, randomPassword);

            if (!result.Succeeded)
            {
                return(false);
            }

            await _userService.AddUserToRolesAsync(user, userInputVm.Roles);

            var context = _httpContextAccessor.HttpContext;
            var code    = await _userService.GenerateEmailConfirmationTokenAsync(user);

            var callbackUrl  = _urlHelperExtension.EmailConfirmationLink(user.Id, code, context.Request.Scheme);
            var emailOptions = new EmailOptions
            {
                Url      = callbackUrl,
                Password = randomPassword,
                UserName = userInputVm.Username
            };

            await _emailSender.SendEmailAsync(userInputVm.Email, "", emailOptions, EmailType.AccountConfirm);

            return(true);
        }
Exemplo n.º 3
0
 public EmailService(
     IOptions <EmailOptions> options,
     ILogger <EmailService> logger)
 {
     _emailOptions = options.Value ?? throw new ArgumentNullException(nameof(options));
     _logger       = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Exemplo n.º 4
0
        private static IServiceCollection AddForEvolveAspNetCore(this IServiceCollection services, ForEvolveAspNetCoreSettings settings)
        {
            // Setup configs
            services.AddSingleton(settings);

            // Error and OperationResults
            services
            .AddForEvolveErrorFactory()
            .AddForEvolveOperationResults()
            ;

            // Others
            services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.TryAddSingleton <IHttpRequestValueFinder, HttpRequestValueFinder>();

            // Emails
            services.TryAddScoped <IViewRenderer, ViewRenderer>();
            services.TryAddSingleton <IEmailSender, DefaultEmailSender>();
            var emailOptions = new EmailOptions();

            settings.Configuration?.Bind(settings.EmailOptionsConfigurationKey, emailOptions);
            services.TryAddSingleton(emailOptions);

            return(services);
        }
Exemplo n.º 5
0
        public async Task SendEmailAsync(EmailOptions emailOptions)
        {
            var    fromAddress  = new MailAddress("*****@*****.**", "Dave Armstrong");
            var    toAddress    = new MailAddress(emailOptions.Email, "Idris");
            string fromPassword = "******";
            string subject      = emailOptions.Subject;
            string body         = emailOptions.Content;

            var smtp = new System.Net.Mail.SmtpClient
            {
                Host           = "smtp.gmail.com",
                Port           = 587,
                EnableSsl      = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                Credentials    = new NetworkCredential(fromAddress.Address, fromPassword),
                Timeout        = 20000
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body,
                IsBodyHtml = true
            })
            {
                smtp.Send(message);
            }
        }
Exemplo n.º 6
0
        public async Task SendEmails(EmailOptions emailOptions)
        {
            MailMessage mail = new MailMessage()
            {
                Subject    = emailOptions.Subject,
                Body       = emailOptions.Body,
                From       = new MailAddress(_smtpConfig.SenderAddress, _smtpConfig.SenderDisplayName),
                IsBodyHtml = _smtpConfig.IsBodyHtml
            };

            foreach (var receiver in emailOptions.EmailReceivers)
            {
                mail.To.Add(receiver);
            }

            NetworkCredential networkCredential = new NetworkCredential(_smtpConfig.UserName, _smtpConfig.Password);

            SmtpClient smtpClient = new SmtpClient()
            {
                Host                  = _smtpConfig.Host,
                Port                  = _smtpConfig.Port,
                EnableSsl             = _smtpConfig.EnableSSL,
                UseDefaultCredentials = _smtpConfig.UseDefaultCredential,
                Credentials           = networkCredential,
            };

            mail.BodyEncoding = Encoding.Default;
            await smtpClient.SendMailAsync(mail);
        }
Exemplo n.º 7
0
        private async Task SendEmail(EmailOptions emailOptions)
        {
            MailMessage mail = new MailMessage()
            {
                Subject    = emailOptions.Subject,
                Body       = emailOptions.Body,
                From       = new MailAddress(_smtpOptions.SenderAddress, _smtpOptions.SenderDisplayName),
                IsBodyHtml = _smtpOptions.IsBodyHtml
            };

            foreach (var email in emailOptions.EmailReceivers)
            {
                mail.To.Add(email);
            }

            NetworkCredential networkCredential = new NetworkCredential(_smtpOptions.UserName, _smtpOptions.Password);

            SmtpClient smtpClient = new SmtpClient
            {
                Host                  = _smtpOptions.Host,
                Port                  = _smtpOptions.Port,
                EnableSsl             = _smtpOptions.EnableSSL,
                UseDefaultCredentials = true,
                Credentials           = networkCredential
            };

            //SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
            //smtpClient.UseDefaultCredentials = true;
            //smtpClient.EnableSsl = true;
            //smtpClient.Credentials = networkCredential;
            mail.BodyEncoding = Encoding.Default;

            await smtpClient.SendMailAsync(mail);
        }
Exemplo n.º 8
0
        public async Task SendTestEmail(EmailOptions emailOptions)
        {
            emailOptions.Subject = UpdatePlaceHolders("Greetings {{Username}}.", emailOptions.PlaceHolders);
            emailOptions.Body    = UpdatePlaceHolders(GetEmailBody("Email"), emailOptions.PlaceHolders);

            await SendEmail(emailOptions);
        }
Exemplo n.º 9
0
        public async Task SendEmailVerificationEmail(EmailOptions emailOptions)
        {
            emailOptions.Subject = UpdatePlaceHolders("Please verify your email.", emailOptions.PlaceHolders);
            emailOptions.Body    = UpdatePlaceHolders(GetEmailBody("EmailVerification"), emailOptions.PlaceHolders);

            await SendEmail(emailOptions);
        }
Exemplo n.º 10
0
    public static EmailOptions ReadFromConfiguration(IConfiguration config, AppOptions appOptions)
    {
        var options = new EmailOptions();

        options.EnableDailySummary       = config.GetValue(nameof(options.EnableDailySummary), appOptions.AppMode == AppMode.Production);
        options.AllowedOutboundAddresses = config.GetValueList(nameof(options.AllowedOutboundAddresses)).Select(v => v.ToLowerInvariant()).ToList();
        options.TestEmailAddress         = config.GetValue(nameof(options.TestEmailAddress), appOptions.AppMode == AppMode.Development ? "test@localhost" : "");

        string emailConnectionString = config.GetConnectionString("Email");

        if (!String.IsNullOrEmpty(emailConnectionString))
        {
            var uri = new SmtpUri(emailConnectionString);
            options.SmtpHost     = uri.Host;
            options.SmtpPort     = uri.Port;
            options.SmtpUser     = uri.User;
            options.SmtpPassword = uri.Password;
        }

        options.SmtpFrom       = config.GetValue(nameof(options.SmtpFrom), appOptions.AppMode == AppMode.Development ? "Exceptionless <noreply@localhost>" : "");
        options.SmtpEncryption = config.GetValue(nameof(options.SmtpEncryption), GetDefaultSmtpEncryption(options.SmtpPort));

        if (String.IsNullOrWhiteSpace(options.SmtpUser) != String.IsNullOrWhiteSpace(options.SmtpPassword))
        {
            throw new ArgumentException("Must specify both the SmtpUser and the SmtpPassword, or neither.");
        }

        return(options);
    }
Exemplo n.º 11
0
 public SendGridEmailService(HttpClient httpClient, IFileService fileService, SendGridOptions sendGridOptions, EmailOptions emailOptions)
 {
     _httpClient      = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
     _fileService     = fileService ?? throw new ArgumentNullException(nameof(fileService));
     _sendGridOptions = sendGridOptions ?? throw new ArgumentNullException(nameof(sendGridOptions));
     _emailOptions    = emailOptions ?? throw new ArgumentNullException(nameof(emailOptions));
 }
Exemplo n.º 12
0
 public ChangeEmailController(IEmailPublisher email, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IOptions <EmailOptions> options)
 {
     _email         = email;
     _userManager   = userManager;
     _signInManager = signInManager;
     _options       = options.Value;
 }
Exemplo n.º 13
0
        public async Task SendEmailAsync(EmailEnvelop emailEnvelop, EmailOptions emailOptions = null)
        {
            if (emailOptions == null)
            {
                emailOptions = _emailOptions.CurrentValue;
            }

            if (emailOptions.SkipMode)
            {
                return;
            }

            var client = new SmtpClient(emailOptions.Host, emailOptions.Port)
            {
                Credentials = new NetworkCredential(emailOptions.UserName, emailOptions.Password),
                EnableSsl   = emailOptions.EnableSSL
            };

#pragma warning disable CA2000 // Dispose objects before losing scope
            await client.SendMailAsync(
                new MailMessage(emailOptions.From, emailEnvelop?.To, emailEnvelop.Subject, emailEnvelop.Body)
                { IsBodyHtml = true }
                ).ConfigureAwait(false);

#pragma warning restore CA2000 // Dispose objects before losing scope

            client.Dispose();
        }
Exemplo n.º 14
0
 public EmailService(
     IOptions <EmailOptions> emailOptions,
     IHostingEnvironment env)
 {
     _emailOptions = emailOptions.Value;
     _env          = env;
 }
Exemplo n.º 15
0
        public void CreateMimeMessage_GeneratesMimeMessageCorrectly()
        {
            // Arrange
            string emailAddress = "*****@*****.**";
            string subject      = "subject";
            string message      = "message";

            EmailOptions emailOptions = new EmailOptions();

            Mock <IOptions <EmailOptions> > mockOptions = new Mock <IOptions <EmailOptions> >();

            mockOptions.Setup(o => o.Value).Returns(emailOptions);

            EmailService emailSender = new EmailService(mockOptions.Object, null);

            // Act
            MimeMessage mimeMessage = emailSender.CreateMimeMessage(emailAddress, subject, message);

            // Assert
            mockOptions.VerifyAll();
            Assert.Equal(message, mimeMessage.TextBody);
            Assert.Equal(subject, mimeMessage.Subject);
            Assert.Equal($"\"{emailAddress}\" <{emailAddress}>", mimeMessage.To.ToString());
            Assert.Equal($"\"{emailOptions.Name}\" <{emailOptions.EmailAddress}>", mimeMessage.From.ToString());
        }
Exemplo n.º 16
0
        private void AddEmailButton_Click(object sender, EventArgs e)
        {
            using (AddEmailDlg dlg = new AddEmailDlg())
            {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    EmailOptions options = new EmailOptions(dlg.EmailAddress, dlg.CooldownTime) // We do need to track changes here because each email has numerous properties
                    {
                        EndTime        = new DateTime(2020, 1, 1, 23, 59, 59),
                        StartTime      = new DateTime(2020, 1, 1, 0, 0, 0),
                        Active         = true,
                        NumberOfImages = 1
                    };

                    _area.Notifications.Email.Add(options);

                    ListViewItem item = new ListViewItem(new string[] { dlg.EmailAddress, dlg.CooldownTime.ToString() });
                    emailsList.Items.Add(item);
                    int index = item.Index;
                    emailsList.Items[index].Tag      = options;
                    emailsList.Items[index].Focused  = true;
                    emailsList.Items[index].Selected = true;

                    SetEmailControls(options);
                    item.Checked = true;
                    emailsList.Select();
                }
            }
        }
Exemplo n.º 17
0
        public async Task <IActionResult> ForgotPassword([FromBody] ForgotPasswordViewModel model)
        {
            var user = await _userService.FindByEmailAsync(model.Email);

            if (user == null || !(await _userService.IsEmailConfirmedAsync(user)))
            {
                return(Ok());
            }

            var token = await _userService.GeneratePasswordResetTokenAsync(user);

            await _userService.ToggleRequestPasswordStatusByEmail(model.Email);

            await _userService.SaveResetPasswordRequest(token, model.Email);

            var callbackUrl  = _urlHelper.ResetPasswordCallbackLink(model.Email, token, Request.Scheme);
            var emailOptions = new EmailOptions
            {
                Url   = callbackUrl,
                Token = token
            };

            await _emailSender.SendEmailAsync(model.Email, "", emailOptions, EmailType.ForgotPassword);

            return(Ok());
        }
        public void SerializeEmailOptions()
        {
            EmailOptions s = new EmailOptions();

            s.FromAddress = TestContext.CurrentContext.Random.GetString();
            s.Host        = TestContext.CurrentContext.Random.GetString();
            s.Password    = new EncryptedData()
            {
                Data = TestContext.CurrentContext.Random.GetString(),
                Mode = TestContext.CurrentContext.Random.Next(),
                Salt = TestContext.CurrentContext.Random.GetString()
            };
            s.Port = TestContext.CurrentContext.Random.Next();
            s.UseDefaultCredentials = true;
            s.Username = TestContext.CurrentContext.Random.GetString();
            s.UseSsl   = true;

            EmailOptions n = JsonConvert.DeserializeObject <EmailOptions>(JsonConvert.SerializeObject(s));

            Assert.AreEqual(s.FromAddress, n.FromAddress);
            Assert.AreEqual(s.Host, n.Host);
            Assert.AreEqual(s.Password.Salt, n.Password.Salt);
            Assert.AreEqual(s.Password.Mode, n.Password.Mode);
            Assert.AreEqual(s.Password.Data, n.Password.Data);
            Assert.AreEqual(s.Port, n.Port);
            Assert.AreEqual(s.UseDefaultCredentials, n.UseDefaultCredentials);
            Assert.AreEqual(s.Username, n.Username);
            Assert.AreEqual(s.UseSsl, n.UseSsl);
        }
Exemplo n.º 19
0
 public EmailViewModel(EmailOptions model, RandomNumberGenerator rng, INotifiableEventPublisher eventPublisher)
 {
     this.model       = model;
     this.rng         = rng;
     this.DisplayName = "Email";
     eventPublisher.Register(this);
 }
Exemplo n.º 20
0
        public EmailSender(
            IEnumerable <IEmailProviderType> emailProviderTypes,
            IOptions <EmailOptions> options,
            IStorageFactory storageFactory,
            ITemplateLoaderFactory templateLoaderFactory)
        {
            this.options = options.Value;

            var providerType = emailProviderTypes
                               .FirstOrDefault(x => x.Name == this.options.Provider.Type);

            if (providerType == null)
            {
                throw new ArgumentNullException("ProviderType", $"The provider type {this.options.Provider.Type} does not exist. Maybe you are missing a reference or an Add method call in your Startup class.");
            }

            this.provider = providerType.BuildProvider(this.options.Provider);

            if (!string.IsNullOrWhiteSpace(this.options.TemplateStorage))
            {
                var store = storageFactory.GetStore(this.options.TemplateStorage);
                if (store == null)
                {
                    throw new ArgumentNullException("TemplateStorage", $"There is no file store configured with name {this.options.TemplateStorage}. Unable to initialize email templating.");
                }

                this.templateLoader = templateLoaderFactory.Create(store);
            }
        }
Exemplo n.º 21
0
        private JObject CreateMessage(EmailOptions options)
        {
            var from = new JObject
            {
                { Constants.Mailjet.Email, this.mailjetApiSettings.Sender },
                { Constants.Mailjet.Name, this.mailjetApiSettings.SenderName }
            };

            var to = new JArray
            {
                new JObject
                {
                    { Constants.Mailjet.Email, options.ToEmail },
                    { Constants.Mailjet.Name, options.ToName }
                }
            };

            var message = new JObject
            {
                { Constants.Mailjet.From, from },
                { Constants.Mailjet.To, to },
                { Constants.Mailjet.Subject, options.Subject }
            };

            return(message);
        }
Exemplo n.º 22
0
        public async Task SendConfirmationEmailAsync(string userName)
        {
            var user = await this.userSharedService.FindByEmailAsync(userName);

            if (!user.EmailConfirmed)
            {
                this.localizer.Get("EmailAlreadyConfirmed");
            }

            var token = await this.userManager.GenerateEmailConfirmationTokenAsync(user);

            var link = this.GenerateConfirmationEmailLink(user, token);

            var settings = new EmailOptions
            {
                Subject    = this.localizer.Get("ConfirmationEmailSubject"),
                ToEmail    = user.Email,
                ToName     = null,
                TemplateId = this.localizer.Get("ConfirmationEmailBody")
            };

            settings.Variables.Add(Constants.Mailjet.Keys.ConfirmationEmailLink, link);

            await this.mailjetService.Send(settings);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Prepare Email options for various system requests
        /// </summary>
        /// <param name="requestViewModel"></param>
        /// <returns></returns>
        private EmailOptions PrepareEmailOptions(RequestViewModel requestViewModel)
        {
            var emailOptions = new EmailOptions();
            var msgBody      = SendGridMailHelper.MailBody(_hostingEnvironment, emailOptions.Template);

            if (!string.IsNullOrEmpty(msgBody))
            {
                emailOptions.Subject = "Request Received - SubQuip";
                emailOptions.CcMail  = new MailUser {
                    Name = requestViewModel.MailUsers[0].Name, Email = requestViewModel.MailUsers[0].Email
                };
                emailOptions.HtmlBody    = msgBody.Replace("{Name}", emailOptions.CcMail.Name).Replace("{Email}", emailOptions.CcMail.Email).Replace("{Company}", requestViewModel.Company).Replace("{PhoneNumber}", requestViewModel.PhoneNumber).Replace("{FromDate}", requestViewModel.FromDate.ToString("dd-MM-yyyy")).Replace("{ToDate}", requestViewModel.ToDate.ToString("dd-MM-yyyy")).Replace("{Description}", requestViewModel.Description).Replace("{Type}", requestViewModel.Type.ToString());
                emailOptions.PlainBody   = string.Empty;
                emailOptions.Template    = MailTemplate.Request;
                emailOptions.ToMailsList = new List <MailUser> {
                    new MailUser {
                        Name = "SubQuip", Email = _configuration["requestEmail"]
                    }
                };
                emailOptions.Attachments = new List <Attachment>
                {
                    new Attachment()
                    {
                        Content     = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(requestViewModel)),
                        Name        = "Request.json",
                        ContentType = "text/json"
                    }
                };
            }
            return(emailOptions);
        }
Exemplo n.º 24
0
 public CssInliner(EmailOptions options)
 {
     if (EmailCssContent == null && options.CssPath != null)
     {
         EmailCssContent = File.ReadAllText(options.CssPath, Encoding.UTF8);
     }
 }
Exemplo n.º 25
0
 public MailgunMessageSender(IMailgunApi api, IOptionsSnapshot <MailgunOptions> mailgunOptions, ILogger <MailgunMessageSender> logger, IOptionsSnapshot <EmailOptions> emailOptions)
 {
     _api            = api;
     _mailgunOptions = mailgunOptions.Value;
     _logger         = logger;
     _emailOptions   = emailOptions.Value;
 }
        /// <summary>
        /// Adds the <c>IEmailSender</c> services to the specified <c>Microsoft.Extensions.DependencyInjection.IServiceCollection</c>.
        /// Default <c>EmailOptions</c> will be used.
        /// </summary>
        /// <param name="services">The <c>Microsoft.Extensions.DependencyInjection.IServiceCollection</c> to add the service to.</param>
        /// <param name="emailOptionsAction">The action used to configure the <c>EmailOptions</c>.</param>
        /// <returns>A reference to this instance after the operation has completed.</returns>
        public static IServiceCollection AddForEvolveEmailSender(this IServiceCollection services, Action <EmailOptions> emailOptionsAction = null)
        {
            var emailOptions = new EmailOptions();

            emailOptionsAction?.Invoke(emailOptions);
            return(services.AddForEvolveEmailSender(emailOptions));
        }
Exemplo n.º 27
0
 private void SizeImageToNumeric_ValueChanged(object sender, EventArgs e)
 {
     if (emailsList.SelectedIndices.Count > 0)
     {
         EmailOptions opt = (EmailOptions)emailsList.Items[emailsList.SelectedIndices[0]].Tag;
         opt.SizeDownToPercent = (int)sizeImageToNumeric.Value;
     }
 }
Exemplo n.º 28
0
 private void NumberOfImages_ValueChanged(object sender, EventArgs e)
 {
     if (emailsList.SelectedIndices.Count > 0)
     {
         EmailOptions opt = (EmailOptions)emailsList.Items[emailsList.SelectedIndices[0]].Tag;
         opt.NumberOfImages = (int)numberOfImages.Value;
     }
 }
Exemplo n.º 29
0
 private void SelectionChanged(object sender, EventArgs e)
 {
     if (emailsList.SelectedItems.Count > 0)
     {
         EmailOptions opt = (EmailOptions)emailsList.SelectedItems[0].Tag; // to avoid clutter
         SetEmailControls(opt);
     }
 }
Exemplo n.º 30
0
 public SecretRekeyProvider(IDialogCoordinator dialogCoordinator, ILogger <SecretRekeyProvider> logger, AuthenticationOptions authnOptions, EmailOptions emailOptions, IProtectedSecretProvider secretProvider)
 {
     this.dialogCoordinator = dialogCoordinator;
     this.logger            = logger;
     this.authnOptions      = authnOptions;
     this.emailOptions      = emailOptions;
     this.secretProvider    = secretProvider;
 }
Exemplo n.º 31
0
        public static void SendEmail(EmailOptions options, string to, string from, string subject, string message)
        {
            var client = new SmtpClient {
                Host = options.SmtpServer,
                Port = options.Port,
                EnableSsl = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(options.Username, options.Password)
            };

            var mailMessage = new MailMessage() {
                From = new MailAddress(from, "CHABS No Reply"),
                To = { to },
                Body = message,
                Subject = subject
            };
            try {
                client.Send(mailMessage);
            } catch (Exception ex) {
                throw new Exception("Could not send email", ex);
            }
        }
Exemplo n.º 32
0
        private bool sendMessage(Email mail, EmailOptions options)
        {
            try
            {
                int port;
                int.TryParse(options.SmtpPort, out port);
                //Настройки сервера
                SmtpClient Smtp = new SmtpClient(options.SmtpServer, port)
                {
                    Credentials = new NetworkCredential(options.User, options.Password),
                    EnableSsl = true,
                    Timeout = 60000
                };

                //Формирование письма
                MailMessage Message = new MailMessage
                {
                    From = new MailAddress(options.EmailSender, options.Sender, Encoding.UTF8),
                    Subject = mail.Topic,
                    Body = mail.Body,
                    HeadersEncoding = Encoding.UTF8,
                    SubjectEncoding = Encoding.UTF8
                };

                //Формирование MailTo
                string[] mailToGroup = mail.SendTo.Split(';');
                foreach (string ardess in mailToGroup)
                {
                    if (ardess.Trim() != "")
                    {
                        Message.To.Add(new MailAddress(ardess.Trim()));
                    }
                }

                //Send
                Smtp.Send(Message);

                //eventLog.WriteEntry(string.Format("Письмо на адрес: '{0}' отослано!", mail.SendTo));
                return true;
            }
            catch (Exception exp)
            {
                //eventLog.WriteEntry(
                    //string.Format("Произошла ошибка при отправке почты.\r\nСообщение об ошибке: {0}\r\n{1}",
                    //exp.Message, exp.InnerException != null ? exp.InnerException.Message : "..."));

                return false;
            }
        }
 /// <summary>
 /// <para>Sets the authenticated user’s email preferences. POST
 /// </para>
 /// REQUIRES AUTHENTICATION.
 /// </summary>
 /// <param name="request">EmailOptions</param>
 /// <returns>XDocument: EmailOptions.</returns>
 public XDocument SetEmailPreferences(EmailOptions request)
 {
     var query = String.Format(Constants.Culture, "{0}/EmailOptions{1}", Constants.MY_TRADEME, Constants.XML);
     return _connection.Post(request, query, true);
 }
Exemplo n.º 34
0
        /// <summary>
        /// <para>Sets the authenticated user’s email preferences. POST
        /// </para>
        /// REQUIRES AUTHENTICATION.
        /// </summary>
        /// <param name="request">EmailOptions</param>
        /// <returns>XDocument: EmailOptions.</returns>
        public XDocument SetEmailPreferences(EmailOptions request)
        {
            if (_myTradeMe == null)
            {
                _myTradeMe = new MyTradeMeMethods(_connection);
            }

            return _myTradeMe.SetEmailPreferences(request);
        }