OSDN Git Service

add office365 function
authorT.N <dangerouswoo@gmail.com>
Thu, 2 Sep 2021 08:03:29 +0000 (17:03 +0900)
committerT.N <dangerouswoo@gmail.com>
Thu, 2 Sep 2021 08:03:29 +0000 (17:03 +0900)
MailDivSender/Properties/Settings.Designer.cs
MailDivSender/SenderForm.cs
MailDivSender/ServerSettingDlg.Designer.cs
MailDivSender/ServerSettingDlg.cs

index 7e9868d..a3d4248 100644 (file)
@@ -136,5 +136,35 @@ namespace MailDivSender.Properties {
                 this["Signature"] = value;
             }
         }
+
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("")]
+        public string Office365ClientID
+        {
+            get
+            {
+                return ((string)(this["Office365ClientID"]));
+            }
+            set
+            {
+                this["Office365ClientID"] = value;
+            }
+        }
+
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]
+        public bool Office365Enable
+        {
+            get
+            {
+                return ((bool)(this["Office365Enable"]));
+            }
+            set
+            {
+                this["Office365Enable"] = value;
+            }
+        }
     }
 }
index 607a868..32b97ab 100644 (file)
@@ -20,46 +20,6 @@ namespace MailDivSender
     public partial class SenderForm : Form
     {
         /// <summary>
-        /// IMAP4サーバー
-        /// </summary>
-        public string Imap4Server = string.Empty;
-
-        /// <summary>
-        /// IMAP4有無
-        /// </summary>
-        public bool Imap4Enable = false;
-
-        /// <summary>
-        /// IMAP4送信済みフォルダ
-        /// </summary>
-        public string Imap4Sentfolder = "Sent";
-
-        /// <summary>
-        /// SMTPサーバー
-        /// </summary>
-        public string SMTPServer = string.Empty;
-
-        /// <summary>
-        /// SMTPポート番号
-        /// </summary>
-        public int SMTPPort = 587;
-
-        /// <summary>
-        /// Imapポート番号
-        /// </summary>
-        public int ImapPort = 143;
-
-        /// <summary>
-        /// ユーザー
-        /// </summary>
-        public string User = string.Empty;
-
-        /// <summary>
-        /// パスワード
-        /// </summary>
-        public string Password = string.Empty;
-
-        /// <summary>
         /// 署名
         /// </summary>
         public string Signature = string.Empty;
@@ -221,6 +181,15 @@ namespace MailDivSender
 
             var bResult = await Task.Run<bool>(() =>
             {
+                var Imap4Server = Properties.Settings.Default.Imap4Server;
+                var Imap4Enable = Properties.Settings.Default.Imap4Enable;
+                var ImapPort = Properties.Settings.Default.Imap4Port;
+                var Imap4Sentfolder = Properties.Settings.Default.Imap4Sentfolder;
+                var SMTPServer = Properties.Settings.Default.SMTPServer;
+                var SMTPPort = Properties.Settings.Default.SMTPPort;
+                var User = Properties.Settings.Default.User;
+                var Password = Properties.Settings.Default.Pass;
+
                 try
                 {
                     using (var client = new SmtpClient())
@@ -344,8 +313,6 @@ namespace MailDivSender
         /// <param name="e"></param>
         private void SenderForm_Load(object sender, EventArgs e)
         {
-            LoadSetting();
-
             LoadConfig();
 
             MessageTxt.Text = Properties.Settings.Default.Signature;
@@ -449,24 +416,8 @@ namespace MailDivSender
         {
             using( var dlg = new ServerSettingDlg())
             {
-                if (dlg.ShowDialog(this) == DialogResult.OK)
-                    LoadSetting();
+                dlg.ShowDialog(this);
             }
         }
-
-        /// <summary>
-        /// 設定ロード
-        /// </summary>
-        protected void LoadSetting()
-        {
-            Imap4Server = Properties.Settings.Default.Imap4Server;
-            Imap4Enable = Properties.Settings.Default.Imap4Enable;
-            ImapPort = Properties.Settings.Default.Imap4Port;
-            Imap4Sentfolder = Properties.Settings.Default.Imap4Sentfolder;
-            SMTPServer = Properties.Settings.Default.SMTPServer;
-            SMTPPort = Properties.Settings.Default.SMTPPort;
-            User = Properties.Settings.Default.User;
-            Password = Properties.Settings.Default.Pass;
-        }
     }
 }
index aa558d7..01dabdc 100644 (file)
@@ -35,6 +35,9 @@
             this.OkBtn = new System.Windows.Forms.Button();
             this.CancelBtn = new System.Windows.Forms.Button();
             this.Imap4Grp = new System.Windows.Forms.GroupBox();
+            this.label8 = new System.Windows.Forms.Label();
+            this.Imap4SentfolderTxt = new System.Windows.Forms.TextBox();
+            this.Imap4EnableChk = new System.Windows.Forms.CheckBox();
             this.Imap4ServerPort = new System.Windows.Forms.NumericUpDown();
             this.Imap4ServerTxt = new System.Windows.Forms.TextBox();
             this.label4 = new System.Windows.Forms.Label();
             this.label6 = new System.Windows.Forms.Label();
             this.SignatureTxt = new System.Windows.Forms.TextBox();
             this.label7 = new System.Windows.Forms.Label();
-            this.Imap4EnableChk = new System.Windows.Forms.CheckBox();
-            this.Imap4SentfolderTxt = new System.Windows.Forms.TextBox();
-            this.label8 = new System.Windows.Forms.Label();
+            this.office365Grp = new System.Windows.Forms.GroupBox();
+            this.Office365ClientIDTxt = new System.Windows.Forms.TextBox();
+            this.label9 = new System.Windows.Forms.Label();
+            this.Office365ClientIDEnableChk = new System.Windows.Forms.CheckBox();
             this.Imap4Grp.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.Imap4ServerPort)).BeginInit();
             this.SMTPGrp.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.SMTPServerPort)).BeginInit();
+            this.office365Grp.SuspendLayout();
             this.SuspendLayout();
             // 
             // label1
@@ -92,7 +97,7 @@
             // 
             this.OkBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
             this.OkBtn.DialogResult = System.Windows.Forms.DialogResult.OK;
-            this.OkBtn.Location = new System.Drawing.Point(593, 387);
+            this.OkBtn.Location = new System.Drawing.Point(593, 477);
             this.OkBtn.Name = "OkBtn";
             this.OkBtn.Size = new System.Drawing.Size(75, 23);
             this.OkBtn.TabIndex = 4;
             // 
             this.CancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
             this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
-            this.CancelBtn.Location = new System.Drawing.Point(674, 387);
+            this.CancelBtn.Location = new System.Drawing.Point(674, 477);
             this.CancelBtn.Name = "CancelBtn";
             this.CancelBtn.Size = new System.Drawing.Size(75, 23);
             this.CancelBtn.TabIndex = 4;
             this.Imap4Grp.TabStop = false;
             this.Imap4Grp.Text = "Imap4";
             // 
+            // label8
+            // 
+            this.label8.AutoSize = true;
+            this.label8.Location = new System.Drawing.Point(6, 102);
+            this.label8.Name = "label8";
+            this.label8.Size = new System.Drawing.Size(64, 12);
+            this.label8.TabIndex = 7;
+            this.label8.Text = "Sent Folder";
+            // 
+            // Imap4SentfolderTxt
+            // 
+            this.Imap4SentfolderTxt.Location = new System.Drawing.Point(8, 117);
+            this.Imap4SentfolderTxt.Name = "Imap4SentfolderTxt";
+            this.Imap4SentfolderTxt.Size = new System.Drawing.Size(300, 19);
+            this.Imap4SentfolderTxt.TabIndex = 6;
+            // 
+            // Imap4EnableChk
+            // 
+            this.Imap4EnableChk.AutoSize = true;
+            this.Imap4EnableChk.Location = new System.Drawing.Point(250, 74);
+            this.Imap4EnableChk.Name = "Imap4EnableChk";
+            this.Imap4EnableChk.Size = new System.Drawing.Size(58, 16);
+            this.Imap4EnableChk.TabIndex = 5;
+            this.Imap4EnableChk.Text = "Enable";
+            this.Imap4EnableChk.UseVisualStyleBackColor = true;
+            // 
             // Imap4ServerPort
             // 
             this.Imap4ServerPort.Location = new System.Drawing.Point(8, 73);
             this.SignatureTxt.Location = new System.Drawing.Point(366, 32);
             this.SignatureTxt.Multiline = true;
             this.SignatureTxt.Name = "SignatureTxt";
-            this.SignatureTxt.Size = new System.Drawing.Size(382, 336);
+            this.SignatureTxt.Size = new System.Drawing.Size(382, 426);
             this.SignatureTxt.TabIndex = 7;
             // 
             // label7
             this.label7.TabIndex = 8;
             this.label7.Text = "署名";
             // 
-            // Imap4EnableChk
-            // 
-            this.Imap4EnableChk.AutoSize = true;
-            this.Imap4EnableChk.Location = new System.Drawing.Point(250, 74);
-            this.Imap4EnableChk.Name = "Imap4EnableChk";
-            this.Imap4EnableChk.Size = new System.Drawing.Size(58, 16);
-            this.Imap4EnableChk.TabIndex = 5;
-            this.Imap4EnableChk.Text = "Enable";
-            this.Imap4EnableChk.UseVisualStyleBackColor = true;
-            // 
-            // Imap4SentfolderTxt
-            // 
-            this.Imap4SentfolderTxt.Location = new System.Drawing.Point(8, 117);
-            this.Imap4SentfolderTxt.Name = "Imap4SentfolderTxt";
-            this.Imap4SentfolderTxt.Size = new System.Drawing.Size(300, 19);
-            this.Imap4SentfolderTxt.TabIndex = 6;
-            // 
-            // label8
-            // 
-            this.label8.AutoSize = true;
-            this.label8.Location = new System.Drawing.Point(6, 102);
-            this.label8.Name = "label8";
-            this.label8.Size = new System.Drawing.Size(64, 12);
-            this.label8.TabIndex = 7;
-            this.label8.Text = "Sent Folder";
+            // office365Grp
+            // 
+            this.office365Grp.Controls.Add(this.Office365ClientIDEnableChk);
+            this.office365Grp.Controls.Add(this.Office365ClientIDTxt);
+            this.office365Grp.Controls.Add(this.label9);
+            this.office365Grp.Location = new System.Drawing.Point(14, 375);
+            this.office365Grp.Name = "office365Grp";
+            this.office365Grp.Size = new System.Drawing.Size(322, 84);
+            this.office365Grp.TabIndex = 9;
+            this.office365Grp.TabStop = false;
+            this.office365Grp.Text = "office365";
+            // 
+            // Office365ClientIDTxt
+            // 
+            this.Office365ClientIDTxt.Location = new System.Drawing.Point(13, 32);
+            this.Office365ClientIDTxt.Name = "Office365ClientIDTxt";
+            this.Office365ClientIDTxt.Size = new System.Drawing.Size(300, 19);
+            this.Office365ClientIDTxt.TabIndex = 9;
+            // 
+            // label9
+            // 
+            this.label9.AutoSize = true;
+            this.label9.Location = new System.Drawing.Point(11, 15);
+            this.label9.Name = "label9";
+            this.label9.Size = new System.Drawing.Size(46, 12);
+            this.label9.TabIndex = 8;
+            this.label9.Text = "ClientID";
+            // 
+            // Office365ClientIDEnableChk
+            // 
+            this.Office365ClientIDEnableChk.AutoSize = true;
+            this.Office365ClientIDEnableChk.Location = new System.Drawing.Point(252, 57);
+            this.Office365ClientIDEnableChk.Name = "Office365ClientIDEnableChk";
+            this.Office365ClientIDEnableChk.Size = new System.Drawing.Size(58, 16);
+            this.Office365ClientIDEnableChk.TabIndex = 10;
+            this.Office365ClientIDEnableChk.Text = "Enable";
+            this.Office365ClientIDEnableChk.UseVisualStyleBackColor = true;
+            this.Office365ClientIDEnableChk.CheckedChanged += new System.EventHandler(this.Office365ClientIDEnableChk_CheckedChanged);
             // 
             // ServerSettingDlg
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(761, 424);
+            this.ClientSize = new System.Drawing.Size(761, 514);
+            this.Controls.Add(this.office365Grp);
             this.Controls.Add(this.label7);
             this.Controls.Add(this.SignatureTxt);
             this.Controls.Add(this.SMTPGrp);
             this.SMTPGrp.ResumeLayout(false);
             this.SMTPGrp.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.SMTPServerPort)).EndInit();
+            this.office365Grp.ResumeLayout(false);
+            this.office365Grp.PerformLayout();
             this.ResumeLayout(false);
             this.PerformLayout();
 
         private System.Windows.Forms.CheckBox Imap4EnableChk;
         private System.Windows.Forms.Label label8;
         private System.Windows.Forms.TextBox Imap4SentfolderTxt;
+        private System.Windows.Forms.GroupBox office365Grp;
+        private System.Windows.Forms.CheckBox Office365ClientIDEnableChk;
+        private System.Windows.Forms.TextBox Office365ClientIDTxt;
+        private System.Windows.Forms.Label label9;
     }
 }
\ No newline at end of file
index 9b65b6f..10d9116 100644 (file)
@@ -48,7 +48,8 @@ namespace MailDivSender
             Properties.Settings.Default.SMTPServer = SMTPServerTxt.Text;
             Properties.Settings.Default.SMTPPort = (int)SMTPServerPort.Value;
             Properties.Settings.Default.Signature = SignatureTxt.Text;
-
+            Properties.Settings.Default.Office365ClientID = Office365ClientIDTxt.Text;
+            Properties.Settings.Default.Office365Enable = Office365ClientIDEnableChk.Checked;
             Properties.Settings.Default.Save();
         }
 
@@ -66,6 +67,8 @@ namespace MailDivSender
             SMTPServerTxt.Text = Properties.Settings.Default.SMTPServer;
             SMTPServerPort.Value = Properties.Settings.Default.SMTPPort;
             SignatureTxt.Text = Properties.Settings.Default.Signature;
+            Office365ClientIDTxt.Text = Properties.Settings.Default.Office365ClientID;
+            Office365ClientIDEnableChk.Checked = Properties.Settings.Default.Office365Enable;
         }
 
         /// <summary>
@@ -77,5 +80,28 @@ namespace MailDivSender
         {
             LoadSetting();
         }
+
+        /// <summary>
+        /// Office365有無変更発生
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void Office365ClientIDEnableChk_CheckedChanged(object sender, EventArgs e)
+        {
+            if (Office365ClientIDEnableChk.Checked == true)
+            {
+                Imap4Grp.Enabled = false;
+                SMTPGrp.Enabled = false;
+                UserTxt.Enabled = false;
+                PassTxt.Enabled = false;
+            }
+            else
+            {
+                Imap4Grp.Enabled = true;
+                SMTPGrp.Enabled = true;
+                UserTxt.Enabled = true;
+                PassTxt.Enabled = true;
+            }
+        }
     }
 }