/// <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(); }
/// <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(); } }
/// <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); }