Esempio n. 1
0
        /// <summary>
        /// 画面のアカウント設定を取得する。
        /// </summary>
        private void SetAccount()
        {
            Account_DS.AccountRow row = null;
            switch (this._type)
            {
            case AccountSettingType.New:
                //新規の場合は新規行を作成
                row = this._ads.Account.NewAccountRow();
                break;

            case AccountSettingType.Edit:
                //編集の場合は編集行を設定
                row = this._ads.Account.FindByAccountName(this._beforeAccountName);
                break;
            }

            //画面の情報を取り込む
            row.AccountName      = this.txtAccount.Text;
            row.SmtpServer       = this.txtSmtpServer.Text;
            row.SmtpSenderName   = this.txtSenderName.Text;
            row.SmtpSenderMail   = this.txtSenderMail.Text;
            row.SmtpPort         = int.Parse(this.txtSmtpPort.Text);
            row.UsePopBeforeSmtp = this.chkPopBeforeSmtp.Checked;
            row.UseSmtpAuth      = this.chkSmtpAuth.Checked;
            row.PopServer        = this.txtPopServer.Text;
            row.PopUserId        = this.txtPopUser.Text;
            row.PopPassword      = CryptographyUtil.EncryptString(this.txtPopPassword.Text);
            row.PopPort          = int.Parse(this.txtPopPort.Text);

            if (this._type == AccountSettingType.New)
            {
                this._ads.Account.AddAccountRow(row);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// ドロップダウンに表示されている設定情報を表示する。
        /// </summary>
        private void ShowAccount()
        {
            Account_DS.AccountRow row = this._ads.Account.FindByAccountName(this.cboAccount.SelectedValue.ToString());

            this.txtAccount.Text          = row.AccountName;
            this.txtSmtpServer.Text       = row.SmtpServer;
            this.txtSenderName.Text       = row.SmtpSenderName;
            this.txtSenderMail.Text       = row.SmtpSenderMail;
            this.txtSmtpPort.Text         = row.SmtpPort.ToString();
            this.chkPopBeforeSmtp.Checked = row.UsePopBeforeSmtp;
            this.chkSmtpAuth.Checked      = row.UseSmtpAuth;
            this.txtPopServer.Text        = row.PopServer;
            this.txtPopUser.Text          = row.PopUserId;
            this.txtPopPassword.Text      = CryptographyUtil.DecryptString(row.PopPassword);
            this.txtPopPort.Text          = row.PopPort.ToString();

            this._isAccountEdited   = false;
            this._beforeAccountName = this.cboAccount.SelectedValue.ToString();
        }
Esempio n. 3
0
        /// <summary>
        /// Pop Before SMTPを行う。
        /// </summary>
        /// <param name="accountRow">アカウント情報</param>
        private void DoPopBeforeSMTP(Account_DS.AccountRow accountRow)
        {
            System.Net.Sockets.TcpClient tcp = new System.Net.Sockets.TcpClient();
            tcp.Connect(accountRow.PopServer, accountRow.PopPort);
            Stream ns = tcp.GetStream();

            using (StreamWriter sw = new StreamWriter(ns))
                using (StreamReader sr = new StreamReader(ns))
                {
                    sw.NewLine   = "\r\n";
                    sw.AutoFlush = true;
                    sr.ReadLine();
                    sw.WriteLine("USER {0}", accountRow.PopUserId);
                    sr.ReadLine();
                    sw.WriteLine("PASS {0}", CryptographyUtil.DecryptString(accountRow.PopPassword));
                    sr.ReadLine();
                    if (tcp.Connected)
                    {
                        sw.WriteLine("QUIT");
                        sr.ReadLine();
                    }
                    tcp.Close();
                }
        }
Esempio n. 4
0
        /// <summary>
        /// smtpクライアントを作成する。
        /// </summary>
        /// <param name="accountRow">アカウント情報</param>
        /// <returns>smtpクライアント</returns>
        private TKMP.Net.SmtpClient CreateSMTPClient(Account_DS.AccountRow accountRow)
        {
            TKMP.Net.SmtpClient smtp = null;

            if (accountRow.UseSmtpAuth == true)
            {
                //SMTPサーバーで認証を利用する場合
                TKMP.Net.ISmtpLogon logon = new TKMP.Net.AuthLogin(accountRow.PopUserId, CryptographyUtil.DecryptString(accountRow.PopPassword));
                smtp = new TKMP.Net.SmtpClient(accountRow.SmtpServer, accountRow.SmtpPort, logon);
            }
            else
            {
                //通常送信
                smtp = new TKMP.Net.SmtpClient(accountRow.SmtpServer, accountRow.SmtpPort);
            }

            return(smtp);
        }