/// <summary> /// Sends an email asynchronously. /// </summary> /// <returns>A System.Threading.Tasks.Task that on completion updates the output.</returns> public async Task SendEmailAsync(FWMail mail) { if (mail.Debug && !_settings.Debug) { await Task.FromCanceled(new CancellationToken(true)); } MailMessage message = CreateMessage(mail); using (var smtpClient = new SmtpClient(_settings.Host, _settings.Port)) { var password = _settings.Password; if (_settings.SecurePassword) { var crypto = FWEncryption.Create(); var key = CreateKey(); password = crypto.Decrypt(password, key); } smtpClient.Credentials = new NetworkCredential(_settings.User, password); smtpClient.EnableSsl = _settings.EnableSsl; await smtpClient.SendMailAsync(message); } }
/// <summary> /// Returns the value encrypted. /// </summary> /// <returns>The encrypted value.</returns> public override string ToString() { var encryption = FWEncryption.Create(true); return(encryption.Encrypt(Value.ToString(), _key)); }