Пример #1
0
        public static MailAccount AsMailAccount(this MailAccountEntity source, bool mapPassword = true)
        {
            if (source == null)
            {
                return(null);
            }

            var mapped = new MailAccount
            {
                Enabled         = source.Enabled,
                Id              = source.Id,
                SmtpHost        = source.SmtpHost,
                UserId          = source.UserId,
                SmtpUsername    = source.SmtpUsername,
                User            = source.User.AsMailUser(),
                FromDisplayName = source.FromDisplayName,
                FromAddress     = source.FromAddress,
                EnableSsl       = source.EnableSsl,
                SmtpPort        = source.SmtpPort,
                CreationDateUtc = source.CreationDateUtc,
                RedirectToDisk  = source.RedirectToDisk
            };

            if (mapPassword)
            {
                mapped.SmtpPassword = source.SmtpPassword;
            }

            return(mapped);
        }
Пример #2
0
        public static string GetMailFrom(MailAccount account)
        {
            switch (account)
            {
            case MailAccount.REGISTER:
                return(AppSettings.Setting <string>("registerMail"));

            case MailAccount.INVITATION:
                return(AppSettings.Setting <string>("invitationMail"));

            case MailAccount.ACTIVATION:
                return(AppSettings.Setting <string>("activationMail"));

            case MailAccount.EVENT:
                return(AppSettings.Setting <string>("eventMail"));

            case MailAccount.CONFIRMATION:
                return(AppSettings.Setting <string>("confirmationMail"));

            case MailAccount.DELETE:
                return(AppSettings.Setting <string>("deleteMail"));

            case MailAccount.ADMIN:
            default:
                return(AppSettings.Setting <string>("adminMail"));
            }
        }
Пример #3
0
        public static RnMailClient BuildRnMailClient(
            MailAccount mailAccount = null,
            IRnLogger logger        = null,
            IWebConfig webConfig    = null,
            IDirectory directory    = null)
        {
            // ensure that we have a mail account to work with
            if (mailAccount == null)
            {
                mailAccount = new MailAccount
                {
                    SmtpHost = "mail.goolge.com",
                    SmtpPort = 443,
                    Id       = 1
                };
            }

            // ensure that we have all other required objects
            logger    = logger ?? Substitute.For <IRnLogger>();
            directory = directory ?? Substitute.For <IDirectory>();

            // configure the default web.config reader
            if (webConfig == null)
            {
                webConfig = Substitute.For <IWebConfig>();

                webConfig // override for default behavior
                .GetAppSetting(RnMailClient.DISK_MAIL_FOLDER, @"c:\mails\")
                .Returns(@"c:\mails\");
            }

            return(new RnMailClient(logger, webConfig, mailAccount, directory));
        }
Пример #4
0
        public void SaveItem(MailAccount item)
        {
            item.FullName            = txtFullName.Text;
            item.IceWarpAccountType  = Convert.ToInt32(ddlAccountType.SelectedValue);
            item.IceWarpAccountState = Convert.ToInt32(ddlAccountState.SelectedValue);
            item.IceWarpRespondType  = Convert.ToInt32(ddlRespondType.SelectedValue);
            if (!string.IsNullOrWhiteSpace(txtRespondPeriodInDays.Text))
            {
                item.RespondPeriodInDays = Convert.ToInt32(txtRespondPeriodInDays.Text);
            }
            item.RespondOnlyBetweenDates = chkRespondOnlyBetweenDates.Checked;
            item.RespondFrom             = calRespondFrom.SelectedDate;
            item.RespondTo            = calRespondTo.SelectedDate;
            item.RespondWithReplyFrom = txtRespondWithReplyFrom.Text;
            item.ResponderSubject     = txtSubject.Text;
            item.ResponderMessage     = txtMessage.Text;
            item.ForwardingEnabled    = !string.IsNullOrWhiteSpace(txtForward.Text);
            item.ForwardingAddresses  = Utils.ParseDelimitedString(txtForward.Text, ';', ' ', ',');
            item.DeleteOnForward      = cbDeleteOnForward.Checked;
            item.IsDomainAdmin        = cbDomainAdmin.Checked;

            item.DeleteOlder     = cbDeleteOlder.Checked;
            item.DeleteOlderDays = string.IsNullOrWhiteSpace(txtDeleteOlderDays.Text) ? 0 : Convert.ToInt32(txtDeleteOlderDays.Text);

            item.ForwardOlder     = cbForwardOlder.Checked;
            item.ForwardOlderDays = string.IsNullOrWhiteSpace(txtForwardOlderDays.Text) ? 0 : Convert.ToInt32(txtForwardOlderDays.Text);
            item.ForwardOlderTo   = txtForwardOlderTo.Text;
        }
Пример #5
0
        public IActionResult Create(MailAccountDTO dto)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var db = new DataContext();

                    if (dto.IdMailAccount.HasValue)
                    {
                        var mail = db.MailAccounts.Find(dto.IdMailAccount.Value);

                        mail.Description = dto.Description;
                        mail.Server      = dto.Server;
                        mail.Port        = dto.Port;
                        mail.Username    = dto.Username;
                        mail.Password    = dto.Password;
                        mail.UseSSL      = dto.UseSSL;

                        //db.Entry(mail).State = EntityState.Modified;

                        db.Update(mail);

                        db.SaveChanges();
                    }
                    else
                    {
                        var mail = new MailAccount
                        {
                            IdMailAccount = Guid.NewGuid(),
                            Description   = dto.Description,
                            Server        = dto.Server,
                            Port          = dto.Port,
                            Username      = dto.Username,
                            Password      = dto.Password,
                            UseSSL        = dto.UseSSL
                        };



                        db.MailAccounts.Add(mail);

                        db.SaveChanges();
                    }



                    return(RedirectToAction("Index"));
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", e.Message);

                    Console.WriteLine(e);
                    //throw;
                }
            }

            return(View(dto));
        }
Пример #6
0
 public void AddAccount(MailAccount newAccount) {
     accounts.Add(newAccount);
     File mailDir = node.fileSystem.rootFile.GetFile("mail");
     File usersDir = mailDir.GetFile($"users");
     if (usersDir == null || !usersDir.IsFolder()) {
         if (usersDir != null)
             usersDir.RemoveFile();
         usersDir = File.CreateNewFolder(node.fileSystem.fileSystemManager, node, mailDir, "users");
         SetFileAsRoot(usersDir);
     }
     File userDir = usersDir.GetFile(newAccount.accountName);
     if (userDir == null || !userDir.IsFolder()) {
         if (userDir != null)
             userDir.RemoveFile();
         userDir = File.CreateNewFolder(node.fileSystem.fileSystemManager, node, usersDir, newAccount.accountName);
         SetFileAsRoot(userDir);
     }
     File inboxDir = userDir.GetFile("Inbox");
     File sentDir = userDir.GetFile("Sent");
     if (inboxDir == null || !inboxDir.IsFolder()) {
         if (inboxDir != null)
             inboxDir.RemoveFile();
         inboxDir = File.CreateNewFolder(node.fileSystem.fileSystemManager, node, userDir, "Inbox");
         SetFileAsRoot(inboxDir);
     }
     if (sentDir == null || !sentDir.IsFolder()) {
         if (sentDir != null)
             sentDir.RemoveFile();
         sentDir = File.CreateNewFolder(node.fileSystem.fileSystemManager, node, userDir, "Sent");
         SetFileAsRoot(sentDir);
     }
     UpdateAccountDatabase();
 }
Пример #7
0
 public Configuration(MailAccount pMailAccount)
 {
     InitializeComponent();
     this.iMailAccount        = pMailAccount;
     this.tbxAlias.Text       = this.iMailAccount.Alias;
     this.tbxMailAddress.Text = this.iMailAccount.MailAddress.Value;
 }
Пример #8
0
        public void EnableEmail(string server, string port, string username, string password, string content, LoginInfo info)
        {
            if (!int.TryParse(port, out int smtpPort))
            {
                throw new Exception("端口错误,不是有效数字");
            }
            var         key         = SystemKey.EMAIL.ToString();
            MailAccount mailAccount = new MailAccount()
            {
                enable     = true,
                password   = password,
                userName   = username,
                smtpServer = server,
                smtpPort   = smtpPort,
                content    = content
            };

            if (SysDB.Exist(key))
            {
                SysDB.Update(key, mailAccount.ToJsonString());
            }
            else
            {
                SysDB.Insert(key, mailAccount.ToJsonString());
            }
            ServerContext.logger.Info($"{info.username}开启了邮件通知");
        }
Пример #9
0
        public static void Send(MailMessage message, MailAccount account)
        {
            try
            {
                using (var client = new SmtpClient())
                {
#if DEBUG
                    // On production should be properly configured IIS.
                    ServicePointManager.ServerCertificateValidationCallback =
                        delegate(object s, X509Certificate certificate,
                                 X509Chain chain, SslPolicyErrors sslPolicyErrors)
                    { return(true); };
#endif
                    var smtp = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp");

                    client.Port                  = smtp.Network.Port;
                    client.Host                  = smtp.Network.Host;
                    client.EnableSsl             = smtp.Network.EnableSsl;
                    client.Timeout               = 10000;
                    client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    client.UseDefaultCredentials = false;
                    client.Credentials           = getNetworkCredential(account);
                    client.Send(message);
                }

                Log.Info(string.Format("Wiadomość została wysłana do {0}", message.To.ToString()));
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("Wystąpił błąd podczas wysyłania wiadomości do {0}", message.To.ToString()));
                Log.Error(ex.Message);
                Log.Error(ex.StackTrace);
            }
        }
Пример #10
0
        public ActionResult DeleteForm(string keyValue, string type)
        {
            EmailConfigEntity configEntity = emailConfigIBLL.GetCurrentConfig();
            MailAccount       account      = new MailAccount();

            account.POP3Host    = configEntity.F_POP3Host;
            account.POP3Port    = configEntity.F_POP3Port.ToInt();
            account.SMTPHost    = configEntity.F_SMTPHost;
            account.SMTPPort    = configEntity.F_SMTPPort.ToInt();
            account.Account     = configEntity.F_Account;
            account.AccountName = configEntity.F_SenderName;
            account.Password    = configEntity.F_Password;
            account.Ssl         = configEntity.F_Ssl == 1 ? true : false;
            if (type == "1")
            {
                //emailIBLL.DeleteMail(account, keyValue);
                emailSendIBLL.DeleteEntity(keyValue);
            }
            else
            {
                var entity = emailReceiveIBLL.GetReceiveEntity(keyValue);
                emailIBLL.DeleteMail(account, entity.F_MID);
                emailReceiveIBLL.DeleteEntity(keyValue);
            }
            return(Success("删除成功!"));
        }
Пример #11
0
        public void Send(int pMailAccountId, string pProtocolName, IEnumerable <string> pToMailAddresses, string pSubject, string pBody)
        {
            try
            {
                //se obtiene la cuenta del usuario activo
                MailAccount mMailAccount = this.iMailAccountRepository.Single(MailAccountSelector.ById(pMailAccountId));

                //se crea el mensaje
                MailMessage mMailMessage = new Shared.MailMessage()
                {
                    Subject = pSubject,
                    To      = pToMailAddresses.Select(bMailAddress => new Shared.MailAddress()
                    {
                        Value = bMailAddress
                    }).ToList(),
                    Body = pBody
                };

                mMailMessage.From = mMailAccount.MailAddress;
                //guardar el mensaje en el repositorio
                mMailAccount.MailAddress.FromMessages.Add(mMailMessage);
                mMailMessage.To       = this.ResolveDbMailAddresses(mMailMessage.To).ToList();
                mMailMessage.DateSent = DateTime.Now.ToShortDateString();
                MCDAL.Instance.Save();

                this.Send(pProtocolName, mMailAccount.GetMailServiceHost(), mMailAccount.MailAddress.Value, this.iEncryptor.Decrypt(mMailAccount.Password), mMailMessage);
            }
            catch (Exception bException)
            {
                throw new FailOnSend(Resources.Exceptions.MailService_Send_FailOnSend, bException);
            }
        }
Пример #12
0
        public ActionResult UnarchiveMail(Int64 mailId, Int64 mailAccountId = 0)
        {
            ISession     session = NHibernateManager.OpenSession();
            ITransaction tran    = session.BeginTransaction();

            try
            {
                MailAccount currentMailAccount = this.GetMailAccount(mailAccountId);
                Mail        mail       = new Mail(mailId, session);
                Label       inboxLabel = Label.FindBySystemName(currentMailAccount, "Inbox", session);
                mail.Unarchive(inboxLabel, session);    //DB
                tran.Commit();
                currentMailAccount.UnarchiveMail(mail); //IMAP

                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exc)
            {
                tran.Rollback();
                Log.LogException(exc, "Parametros del metodo: mailId(" + mailId.ToString() +
                                 "), mailAccountId(" + mailAccountId.ToString() + ").");
                return(Json(new { success = false, message = "Error al desarchivar mail." }, JsonRequestBehavior.AllowGet));
            }
            finally
            {
                session.Close();
            }
        }
Пример #13
0
        public ActionResult GetMailBody(Int64 id = 0, Int64 mailAccountId = 0)
        {
            ISession session = NHibernateManager.OpenSession();

            try
            {
                MailAccount currentMailAccount = this.GetMailAccount(mailAccountId);
                String      body = currentMailAccount.ReadMail(id, session);

                IList <ExtraEntity> mailExtras = Extra.FindByMailId(id, session);

                if (body.Contains("<img src=\"cid:"))
                {
                    this.InsertEmbeddedExtraUrl(ref body, id, session);
                }

                var returnInfo = this.PrepareBodyMail(body, mailExtras);

                JsonResult result = Json(new { success = true, mail = returnInfo }, JsonRequestBehavior.AllowGet);
                return(result);
            }
            catch (Exception exc)
            {
                Log.LogException(exc, "Error generico GetMailBody. Parametros del mail: idMail(" + id.ToString() + ").");
                return(Json(new { success = false, message = "Error al obtener el cuerpo del mail." }, JsonRequestBehavior.AllowGet));
            }
            finally
            {
                session.Close();
            }
        }
Пример #14
0
        public ActionResult ChangeImportance(Int64 mailId, Boolean isIncrease, Int64 mailAccountId = 0)
        {
            ISession     session = NHibernateManager.OpenSession();
            ITransaction tran    = session.BeginTransaction();

            try
            {
                MailAccount currentMailAccount = this.GetMailAccount(mailAccountId);
                Mail        theMail            = new Mail(mailId, session);

                if (isIncrease)
                {
                    theMail.SetImportance((UInt16)(theMail.Entity.Importance + 1), session);
                }
                else
                {
                    theMail.SetImportance((UInt16)(theMail.Entity.Importance - 1), session);
                }
                tran.Commit();
                JsonResult result = Json(new { success = true }, JsonRequestBehavior.AllowGet);
                return(result);
            }
            catch (Exception exc)
            {
                tran.Rollback();
                Log.LogException(exc, "Parametros del metodo: mailId(" + mailId.ToString() +
                                 "), isIncrease(" + isIncrease.ToString() + "), mailAccountId(" + mailAccountId.ToString() + ").");
                return(Json(new { success = false, message = "Error al aumentar importancia." }, JsonRequestBehavior.AllowGet));
            }
            finally
            {
                session.Close();
            }
        }
Пример #15
0
        private static NetworkCredential getNetworkCredential(MailAccount account)
        {
            switch (account)
            {
            case MailAccount.REGISTER:
                return(new NetworkCredential(AppSettings.Setting <string>("registerMail"), AppSettings.Setting <string>("registerPassword")));

            case MailAccount.INVITATION:
                return(new NetworkCredential(AppSettings.Setting <string>("invitationMail"), AppSettings.Setting <string>("invitationPassword")));

            case MailAccount.ACTIVATION:
                return(new NetworkCredential(AppSettings.Setting <string>("activationMail"), AppSettings.Setting <string>("activationPassword")));

            case MailAccount.EVENT:
                return(new NetworkCredential(AppSettings.Setting <string>("eventMail"), AppSettings.Setting <string>("eventPrassword")));

            case MailAccount.CONFIRMATION:
                return(new NetworkCredential(AppSettings.Setting <string>("confirmationMail"), AppSettings.Setting <string>("confirmationPassword")));

            case MailAccount.DELETE:
                return(new NetworkCredential(AppSettings.Setting <string>("deleteMail"), AppSettings.Setting <string>("deletePassword")));

            case MailAccount.ADMIN:
            default:
                return(new NetworkCredential(AppSettings.Setting <string>("adminMail"), AppSettings.Setting <string>("adminPassword")));
            }
        }
Пример #16
0
        public ViewMessage(MailAccount pMailAccount, MailMessage pMailMessage)
        {
            InitializeComponent();
            this.iMailAccount = pMailAccount;
            this.iMailMessage = pMailMessage;

            this.tbFromMailAddress.Text        = pMailMessage.From.Value;
            this.lvToMailAddresses.ItemsSource = pMailMessage.To.Select(bMailMessage => bMailMessage.Value).ToList();
            this.tbxMailSubject.Text           = pMailMessage.Subject;

            HtmlDocument mHtmlDocument = new HtmlDocument();

            mHtmlDocument.LoadHtml(pMailMessage.Body);

            HtmlNode mHtmlNodeBody = mHtmlDocument.DocumentNode.SelectSingleNode("//body");

            if (mHtmlNodeBody != null)
            {
                this.tbBody.NavigateToString(mHtmlNodeBody.OuterHtml);
            }
            else if (!string.IsNullOrEmpty(pMailMessage.Body))
            {
                this.tbBody.NavigateToString(pMailMessage.Body);
            }
        }
Пример #17
0
        /// <summary>
        /// 获取邮件
        /// </summary>
        /// <param name="receiveCount">主键</param>
        /// <returns></returns>
        public ActionResult GetMail()
        {
            EmailConfigEntity entity  = emailConfigIBLL.GetCurrentConfig();
            MailAccount       account = new MailAccount();

            account.POP3Host    = entity.F_POP3Host;
            account.POP3Port    = entity.F_POP3Port.ToInt();
            account.SMTPHost    = entity.F_SMTPHost;
            account.SMTPPort    = entity.F_SMTPPort.ToInt();
            account.Account     = entity.F_Account;
            account.AccountName = entity.F_SenderName;
            account.Password    = entity.F_Password;
            account.Ssl         = entity.F_Ssl == 1 ? true : false;

            var receiveCount      = emailReceiveIBLL.GetCount();
            List <MailModel> data = emailIBLL.GetMail(account, receiveCount);

            for (var i = 0; i < data.Count; i++)
            {
                EmailReceiveEntity receiveEntity = new EmailReceiveEntity();
                receiveEntity.F_Sender     = data[i].To;
                receiveEntity.F_SenderName = data[i].ToName;
                receiveEntity.F_MID        = data[i].UID;
                receiveEntity.F_Subject    = data[i].Subject;
                receiveEntity.F_BodyText   = data[i].BodyText;
                //receiveEntity.Attachment = data[i].Attachment;
                receiveEntity.F_Date = data[i].Date;
                emailReceiveIBLL.SaveReceiveEntity("", receiveEntity);
            }
            return(Success(data));
        }
Пример #18
0
        public IEnumerable <MailDto> ReadMessages(MailAccount mailAccountInput)
        {
            var mailDtoList = new List <MailDto>();

            using (var client = GetImapConnection(mailAccountInput)) {
                var inbox = client.Inbox;
                inbox.Open(FolderAccess.ReadWrite);

                var items = inbox.Fetch(0, -1, MessageSummaryItems.UniqueId | MessageSummaryItems.Size | MessageSummaryItems.Flags);

                foreach (var item in items)
                {
                    var message     = inbox.GetMessage(item.UniqueId);
                    var attachments = GetAttachmentsFromMail(message);

                    mailDtoList.Add(new MailDto {
                        From        = string.Join("|", message.From),
                        Subject     = message.Subject,
                        Attachments = attachments
                    });
                }
            }

            return(mailDtoList);
        }
Пример #19
0
 public void BindItem(MailAccount item)
 {
     chkResponderEnabled.Checked = item.ResponderEnabled;
     txtSubject.Text             = item.ResponderSubject;
     txtMessage.Text             = item.ResponderMessage;
     txtForward.Text             = item.ForwardingAddresses != null?String.Join("; ", item.ForwardingAddresses) : "";
 }
Пример #20
0
 public void SaveItem(MailAccount item)
 {
     item.ResponderEnabled    = chkResponderEnabled.Checked;
     item.ResponderSubject    = txtSubject.Text;
     item.ResponderMessage    = txtMessage.Text;
     item.ForwardingAddresses = Utils.ParseDelimitedString(txtForward.Text, ';', ' ', ',');
 }
Пример #21
0
 public static void RemoveMailAccount(MailAccount newAccount)
 {
     using (SQLiteConnection conn = new SQLiteConnection(DataBasePath))
     {
         conn.Delete(newAccount);
     }
 }
Пример #22
0
 public static void AddMailAccount(MailAccount newAccount)
 {
     using (SQLiteConnection conn = new SQLiteConnection(DataBasePath))
     {
         conn.InsertWithChildren(newAccount);
     }
 }
Пример #23
0
        public ActionResult RemoveLabel(String labelName, Int64 mailId, Boolean isSystemLabel, Int64 mailAccountId = 0)
        {
            ISession     session = NHibernateManager.OpenSession();
            ITransaction tran    = session.BeginTransaction();

            try
            {
                MailAccount currentMailAccount = this.GetMailAccount(mailAccountId);
                Mail        mail = new Mail(mailId, session);

                if (mail.Entity.MailAccountEntity.Id != currentMailAccount.Entity.Id)
                {
                    return(Json(new { success = false, message = "El mail indicado no pertenece a la cuenta indicada." }, JsonRequestBehavior.AllowGet));
                }

                mail.RemoveLabel(labelName, isSystemLabel, session);               //DB
                tran.Commit();
                currentMailAccount.RemoveMailLabel(labelName, mail.Entity.Gm_mid); //IMAP

                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exc)
            {
                tran.Rollback();
                Log.LogException(exc, "Parametros de la llamada: labelName(" + labelName + "), gmID(" + mailId.ToString() + "), mailAccountId(" + mailAccountId + ").");
                return(Json(new { success = false, message = "Error al remover label." }, JsonRequestBehavior.AllowGet));
            }
            finally
            {
                session.Close();
            }
        }
Пример #24
0
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="receiveCount">主键</param>
        /// <returns></returns>
        public ActionResult SendMail(EmailSendEntity entity)
        {
            EmailConfigEntity configEntity = emailConfigIBLL.GetCurrentConfig();
            MailAccount       account      = new MailAccount();

            account.POP3Host    = configEntity.F_POP3Host;
            account.POP3Port    = configEntity.F_POP3Port.ToInt();
            account.SMTPHost    = configEntity.F_SMTPHost;
            account.SMTPPort    = configEntity.F_SMTPPort.ToInt();
            account.Account     = configEntity.F_Account;
            account.AccountName = configEntity.F_SenderName;
            account.Password    = configEntity.F_Password;
            account.Ssl         = configEntity.F_Ssl == 1 ? true : false;
            MailModel model = new MailModel();

            model.UID   = Guid.NewGuid().ToString();
            entity.F_Id = model.UID;
            model.To    = entity.F_To;
            //model.ToName = entity.F_To;
            model.CC = entity.F_CC;
            //model.CCName = entity.F_CC;
            model.Bcc = entity.F_BCC;
            //model.BccName = entity.F_BCC;
            model.Subject  = entity.F_Subject;
            model.BodyText = entity.F_BodyText;
            //model.Attachment = entity.F_Attachment;
            model.Date = entity.F_Date.ToDate();
            emailIBLL.SendMail(account, model);

            entity.F_Sender     = configEntity.F_Account;
            entity.F_SenderName = configEntity.F_SenderName;
            emailSendIBLL.SaveSendEntity("", entity);
            return(Success("发送成功"));
        }
Пример #25
0
 private async void Init(MailAccount pMailAccount)
 {
     this.iUserAccount         = pMailAccount;
     this.iConfigurationPage   = new Configuration(this.iUserAccount);
     this.iDataGridItemsSource = new ObservableCollection <MailMessage>();
     this.tbMailAddress.Text   = iUserAccount.MailAddress.Value;
     await this.UpdateInbox(this.iPageSize);
 }
Пример #26
0
        // constructor
        public RnMailClient(IRnLogger logger, IWebConfig webConfig, MailAccount mailAccount, IDirectory directory = null)
        {
            _logger    = logger;
            _webConfig = webConfig;
            _account   = mailAccount;
            _directory = directory ?? new RnDirectory();

            _mailClient = CreateMailClient();
        }
Пример #27
0
        public void UseDefaultCredentials_GivenHasPassword_ShouldReturnFalse()
        {
            var account = new MailAccount
            {
                SmtpPassword = "******"
            };

            Assert.IsFalse(account.UseDefaultCredentials());
        }
Пример #28
0
        public void UseDefaultCredentials_GivenHasUsername_ShouldReturnFalse()
        {
            var account = new MailAccount
            {
                SmtpUsername = "******"
            };

            Assert.IsFalse(account.UseDefaultCredentials());
        }
Пример #29
0
        public string GetEmailAccount()
        {
            var data = SysDB.Get(SystemKey.EMAIL.ToString());

            if (data == null)
            {
                return(MailAccount.Default().ToJsonString());
            }
            return(data);
        }
Пример #30
0
 /// <summary>
 /// Pide al core que actualice la casilla de correos de la cuenta teniendo en cuenta la cantidad de mensajes que debe descargar
 /// </summary>
 public async Task UpdateInbox(MailAccount pUserAccount, int pWindow = 0)
 {
     try
     {
         await Task.Run(() => this.iMailAccountService.Retrieve(pUserAccount.Id, "pop3", pWindow));
     }
     catch (Exception bException)
     {
         throw new InternalOperationException(Resources.Exceptions.UpdateInboxException, bException);
     }
 }