卓叡 1ヶ月前
コミット
333f9057b4
34個のファイルの変更1312行の追加0行の削除
  1. 22
    0
      SmtpTestForm_ca.sln
  2. 6
    0
      SmtpTestForm_ca/App.config
  3. 44
    0
      SmtpTestForm_ca/My Project/Application.Designer.vb
  4. 12
    0
      SmtpTestForm_ca/My Project/Application.myapp
  5. 32
    0
      SmtpTestForm_ca/My Project/AssemblyInfo.vb
  6. 62
    0
      SmtpTestForm_ca/My Project/Resources.Designer.vb
  7. 117
    0
      SmtpTestForm_ca/My Project/Resources.resx
  8. 73
    0
      SmtpTestForm_ca/My Project/Settings.Designer.vb
  9. 7
    0
      SmtpTestForm_ca/My Project/Settings.settings
  10. 40
    0
      SmtpTestForm_ca/SmtpTestForm.Designer.vb
  11. 120
    0
      SmtpTestForm_ca/SmtpTestForm.resx
  12. 561
    0
      SmtpTestForm_ca/SmtpTestForm.vb
  13. 130
    0
      SmtpTestForm_ca/SmtpTestForm_ca.vbproj
  14. バイナリ
      SmtpTestForm_ca/bin/Debug/SmtpTestForm_ca.exe
  15. 6
    0
      SmtpTestForm_ca/bin/Debug/SmtpTestForm_ca.exe.config
  16. バイナリ
      SmtpTestForm_ca/bin/Debug/SmtpTestForm_ca.pdb
  17. 26
    0
      SmtpTestForm_ca/bin/Debug/SmtpTestForm_ca.xml
  18. 8
    0
      SmtpTestForm_ca/bin/Debug/smtp_config.ini
  19. バイナリ
      SmtpTestForm_ca/n4cbk-unm1w-001.ico
  20. 7
    0
      SmtpTestForm_ca/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.vb
  21. バイナリ
      SmtpTestForm_ca/obj/Debug/DesignTimeResolveAssemblyReferences.cache
  22. バイナリ
      SmtpTestForm_ca/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
  23. バイナリ
      SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.Resources.resources
  24. バイナリ
      SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.SmtpTestForm.resources
  25. バイナリ
      SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.exe
  26. バイナリ
      SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.pdb
  27. バイナリ
      SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.vbproj.AssemblyReference.cache
  28. 1
    0
      SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.vbproj.CoreCompileInputs.cache
  29. 12
    0
      SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.vbproj.FileListAbsolute.txt
  30. バイナリ
      SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.vbproj.GenerateResource.cache
  31. 26
    0
      SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.xml
  32. バイナリ
      SmtpTestForm_ca/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll
  33. バイナリ
      SmtpTestForm_ca/pic/Gemini_Generated_Image_SMTP1.jpg
  34. バイナリ
      SmtpTestForm_ca/pic/n4cbk-unm1w-001.ico

+ 22
- 0
SmtpTestForm_ca.sln ファイルの表示

@@ -0,0 +1,22 @@
1
+
2
+Microsoft Visual Studio Solution File, Format Version 12.00
3
+# Visual Studio Version 17
4
+VisualStudioVersion = 17.12.35728.132 d17.12
5
+MinimumVisualStudioVersion = 10.0.40219.1
6
+Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SmtpTestForm_ca", "SmtpTestForm_ca\SmtpTestForm_ca.vbproj", "{592EBADA-85EC-4658-8F4B-F8819936B798}"
7
+EndProject
8
+Global
9
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
10
+		Debug|Any CPU = Debug|Any CPU
11
+		Release|Any CPU = Release|Any CPU
12
+	EndGlobalSection
13
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
14
+		{592EBADA-85EC-4658-8F4B-F8819936B798}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15
+		{592EBADA-85EC-4658-8F4B-F8819936B798}.Debug|Any CPU.Build.0 = Debug|Any CPU
16
+		{592EBADA-85EC-4658-8F4B-F8819936B798}.Release|Any CPU.ActiveCfg = Release|Any CPU
17
+		{592EBADA-85EC-4658-8F4B-F8819936B798}.Release|Any CPU.Build.0 = Release|Any CPU
18
+	EndGlobalSection
19
+	GlobalSection(SolutionProperties) = preSolution
20
+		HideSolutionNode = FALSE
21
+	EndGlobalSection
22
+EndGlobal

+ 6
- 0
SmtpTestForm_ca/App.config ファイルの表示

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="utf-8" ?>
2
+<configuration>
3
+    <startup>
4
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5
+    </startup>
6
+</configuration>

+ 44
- 0
SmtpTestForm_ca/My Project/Application.Designer.vb ファイルの表示

@@ -0,0 +1,44 @@
1
+'------------------------------------------------------------------------------
2
+' <auto-generated>
3
+'     這段程式碼是由工具產生的。
4
+'     執行階段版本:4.0.30319.42000
5
+'
6
+'     對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼,
7
+'     變更將會遺失。
8
+' </auto-generated>
9
+'------------------------------------------------------------------------------
10
+
11
+Option Strict On
12
+Option Explicit On
13
+
14
+
15
+Namespace My
16
+    
17
+    '注意:這是自動產生的檔案,請勿直接修改它。若要進行變更,
18
+    ' 或者您在這個檔案發生建置錯誤,請到專案設計工具
19
+    ' (移至專案屬性或者在 [方案總管] 中按兩下 [My Project] 節點),
20
+    ' 然後在 [應用程式] 索引標籤上進行變更。
21
+    '
22
+    Partial Friend Class MyApplication
23
+        
24
+        <Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
25
+        Public Sub New()
26
+            MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
27
+            Me.IsSingleInstance = false
28
+            Me.EnableVisualStyles = true
29
+            Me.SaveMySettingsOnExit = true
30
+            Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
31
+        End Sub
32
+        
33
+        <Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
34
+        Protected Overrides Sub OnCreateMainForm()
35
+            Me.MainForm = Global.SmtpTestForm_ca.SmtpTestForm
36
+        End Sub
37
+        
38
+        <Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
39
+        Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
40
+            Me.MinimumSplashScreenDisplayTime = 0
41
+            Return MyBase.OnInitialize(commandLineArgs)
42
+        End Function
43
+    End Class
44
+End Namespace

+ 12
- 0
SmtpTestForm_ca/My Project/Application.myapp ファイルの表示

@@ -0,0 +1,12 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<MyApplicationData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+  <MySubMain>true</MySubMain>
4
+  <MainForm>SmtpTestForm</MainForm>
5
+  <SingleInstance>false</SingleInstance>
6
+  <ShutdownMode>0</ShutdownMode>
7
+  <EnableVisualStyles>true</EnableVisualStyles>
8
+  <AuthenticationMode>0</AuthenticationMode>
9
+  <MinimumSplashScreenDisplayTime>0</MinimumSplashScreenDisplayTime>
10
+  <SaveMySettingsOnExit>true</SaveMySettingsOnExit>
11
+  <HighDpiMpde>false</HighDpiMpde>
12
+</MyApplicationData>

+ 32
- 0
SmtpTestForm_ca/My Project/AssemblyInfo.vb ファイルの表示

@@ -0,0 +1,32 @@
1
+Imports System
2
+Imports System.Reflection
3
+Imports System.Runtime.InteropServices
4
+
5
+' 組件的一般資訊是由下列的屬性集控制。
6
+' 變更這些屬性的值即可修改組件的相關
7
+' 資訊。
8
+
9
+' 檢閱組件屬性的值
10
+
11
+<Assembly: AssemblyTitle("SmtpTestForm_ca")>
12
+<Assembly: AssemblyDescription("")>
13
+<Assembly: AssemblyCompany("")>
14
+<Assembly: AssemblyProduct("SmtpTestForm_ca")>
15
+<Assembly: AssemblyCopyright("Copyright ©  2025")>
16
+<Assembly: AssemblyTrademark("")>
17
+
18
+<Assembly: ComVisible(False)>
19
+
20
+'下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID
21
+<Assembly: Guid("c1666d28-5663-489e-b793-d4cd9613e52b")>
22
+
23
+' 組件的版本資訊由下列四個值所組成: 
24
+'
25
+'      主要版本
26
+'      次要版本
27
+'      組建編號
28
+'      修訂編號
29
+'
30
+
31
+<Assembly: AssemblyVersion("1.0.0.0")>
32
+<Assembly: AssemblyFileVersion("1.0.0.0")>

+ 62
- 0
SmtpTestForm_ca/My Project/Resources.Designer.vb ファイルの表示

@@ -0,0 +1,62 @@
1
+'------------------------------------------------------------------------------
2
+' <auto-generated>
3
+'     This code was generated by a tool.
4
+'     Runtime Version:4.0.30319.42000
5
+'
6
+'     Changes to this file may cause incorrect behavior and will be lost if
7
+'     the code is regenerated.
8
+' </auto-generated>
9
+'------------------------------------------------------------------------------
10
+
11
+Option Strict On
12
+Option Explicit On
13
+
14
+
15
+Namespace My.Resources
16
+
17
+    'This class was auto-generated by the StronglyTypedResourceBuilder
18
+    'class via a tool like ResGen or Visual Studio.
19
+    'To add or remove a member, edit your .ResX file then rerun ResGen
20
+    'with the /str option, or rebuild your VS project.
21
+    '''<summary>
22
+    '''  A strongly-typed resource class, for looking up localized strings, etc.
23
+    '''</summary>
24
+    <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
25
+     Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
26
+     Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
27
+     Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
28
+    Friend Module Resources
29
+
30
+        Private resourceMan As Global.System.Resources.ResourceManager
31
+
32
+        Private resourceCulture As Global.System.Globalization.CultureInfo
33
+
34
+        '''<summary>
35
+        '''  Returns the cached ResourceManager instance used by this class.
36
+        '''</summary>
37
+        <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
38
+        Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
39
+            Get
40
+                If Object.ReferenceEquals(resourceMan, Nothing) Then
41
+                    Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("SmtpTestForm_ca.Resources", GetType(Resources).Assembly)
42
+                    resourceMan = temp
43
+                End If
44
+                Return resourceMan
45
+            End Get
46
+        End Property
47
+
48
+        '''<summary>
49
+        '''  Overrides the current thread's CurrentUICulture property for all
50
+        '''  resource lookups using this strongly typed resource class.
51
+        '''</summary>
52
+        <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
53
+        Friend Property Culture() As Global.System.Globalization.CultureInfo
54
+            Get
55
+                Return resourceCulture
56
+            End Get
57
+            Set(ByVal value As Global.System.Globalization.CultureInfo)
58
+                resourceCulture = value
59
+            End Set
60
+        End Property
61
+    End Module
62
+End Namespace

+ 117
- 0
SmtpTestForm_ca/My Project/Resources.resx ファイルの表示

@@ -0,0 +1,117 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:element name="root" msdata:IsDataSet="true">
64
+      <xsd:complexType>
65
+        <xsd:choice maxOccurs="unbounded">
66
+          <xsd:element name="metadata">
67
+            <xsd:complexType>
68
+              <xsd:sequence>
69
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
70
+              </xsd:sequence>
71
+              <xsd:attribute name="name" type="xsd:string" />
72
+              <xsd:attribute name="type" type="xsd:string" />
73
+              <xsd:attribute name="mimetype" type="xsd:string" />
74
+            </xsd:complexType>
75
+          </xsd:element>
76
+          <xsd:element name="assembly">
77
+            <xsd:complexType>
78
+              <xsd:attribute name="alias" type="xsd:string" />
79
+              <xsd:attribute name="name" type="xsd:string" />
80
+            </xsd:complexType>
81
+          </xsd:element>
82
+          <xsd:element name="data">
83
+            <xsd:complexType>
84
+              <xsd:sequence>
85
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
86
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
87
+              </xsd:sequence>
88
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
89
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
90
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
91
+            </xsd:complexType>
92
+          </xsd:element>
93
+          <xsd:element name="resheader">
94
+            <xsd:complexType>
95
+              <xsd:sequence>
96
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
97
+              </xsd:sequence>
98
+              <xsd:attribute name="name" type="xsd:string" use="required" />
99
+            </xsd:complexType>
100
+          </xsd:element>
101
+        </xsd:choice>
102
+      </xsd:complexType>
103
+    </xsd:element>
104
+  </xsd:schema>
105
+  <resheader name="resmimetype">
106
+    <value>text/microsoft-resx</value>
107
+  </resheader>
108
+  <resheader name="version">
109
+    <value>2.0</value>
110
+  </resheader>
111
+  <resheader name="reader">
112
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
113
+  </resheader>
114
+  <resheader name="writer">
115
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+</root>

+ 73
- 0
SmtpTestForm_ca/My Project/Settings.Designer.vb ファイルの表示

@@ -0,0 +1,73 @@
1
+'------------------------------------------------------------------------------
2
+' <auto-generated>
3
+'     This code was generated by a tool.
4
+'     Runtime Version:4.0.30319.42000
5
+'
6
+'     Changes to this file may cause incorrect behavior and will be lost if
7
+'     the code is regenerated.
8
+' </auto-generated>
9
+'------------------------------------------------------------------------------
10
+
11
+Option Strict On
12
+Option Explicit On
13
+
14
+
15
+Namespace My
16
+
17
+    <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
18
+     Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0"), _
19
+     Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
20
+    Partial Friend NotInheritable Class MySettings
21
+        Inherits Global.System.Configuration.ApplicationSettingsBase
22
+
23
+        Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
24
+
25
+#Region "My.Settings Auto-Save Functionality"
26
+#If _MyType = "WindowsForms" Then
27
+        Private Shared addedHandler As Boolean
28
+
29
+        Private Shared addedHandlerLockObject As New Object
30
+
31
+        <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
32
+        Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
33
+            If My.Application.SaveMySettingsOnExit Then
34
+                My.Settings.Save()
35
+            End If
36
+        End Sub
37
+#End If
38
+#End Region
39
+
40
+        Public Shared ReadOnly Property [Default]() As MySettings
41
+            Get
42
+
43
+#If _MyType = "WindowsForms" Then
44
+                   If Not addedHandler Then
45
+                        SyncLock addedHandlerLockObject
46
+                            If Not addedHandler Then
47
+                                AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
48
+                                addedHandler = True
49
+                            End If
50
+                        End SyncLock
51
+                    End If
52
+#End If
53
+                Return defaultInstance
54
+            End Get
55
+        End Property
56
+    End Class
57
+End Namespace
58
+
59
+Namespace My
60
+
61
+    <Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
62
+     Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
63
+     Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
64
+    Friend Module MySettingsProperty
65
+
66
+        <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
67
+        Friend ReadOnly Property Settings() As Global.SmtpTestForm_ca.My.MySettings
68
+            Get
69
+                Return Global.SmtpTestForm_ca.My.MySettings.Default
70
+            End Get
71
+        End Property
72
+    End Module
73
+End Namespace

+ 7
- 0
SmtpTestForm_ca/My Project/Settings.settings ファイルの表示

@@ -0,0 +1,7 @@
1
+<?xml version='1.0' encoding='utf-8'?>
2
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
3
+  <Profiles>
4
+    <Profile Name="(Default)" />
5
+  </Profiles>
6
+  <Settings />
7
+</SettingsFile>

+ 40
- 0
SmtpTestForm_ca/SmtpTestForm.Designer.vb ファイルの表示

@@ -0,0 +1,40 @@
1
+<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
2
+Partial Class SmtpTestForm
3
+    Inherits System.Windows.Forms.Form
4
+
5
+    'Form 覆寫 Dispose 以清除元件清單。
6
+    <System.Diagnostics.DebuggerNonUserCode()> _
7
+    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
8
+        Try
9
+            If disposing AndAlso components IsNot Nothing Then
10
+                components.Dispose()
11
+            End If
12
+        Finally
13
+            MyBase.Dispose(disposing)
14
+        End Try
15
+    End Sub
16
+
17
+    '為 Windows Form 設計工具的必要項
18
+    Private components As System.ComponentModel.IContainer
19
+
20
+    '注意: 以下為 Windows Form 設計工具所需的程序
21
+    '可以使用 Windows Form 設計工具進行修改。
22
+    '請勿使用程式碼編輯器進行修改。
23
+    <System.Diagnostics.DebuggerStepThrough()> _
24
+    Private Sub InitializeComponent()
25
+        Me.SuspendLayout()
26
+        '
27
+        'SmtpTestForm
28
+        '
29
+        Me.AutoScaleDimensions = New System.Drawing.SizeF(10.0!, 20.0!)
30
+        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
31
+        Me.ClientSize = New System.Drawing.Size(1333, 750)
32
+        Me.Font = New System.Drawing.Font("微軟正黑體", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
33
+        Me.Margin = New System.Windows.Forms.Padding(5, 5, 5, 5)
34
+        Me.Name = "SmtpTestForm"
35
+        Me.Text = "Form1"
36
+        Me.ResumeLayout(False)
37
+
38
+    End Sub
39
+
40
+End Class

+ 120
- 0
SmtpTestForm_ca/SmtpTestForm.resx ファイルの表示

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 561
- 0
SmtpTestForm_ca/SmtpTestForm.vb ファイルの表示

@@ -0,0 +1,561 @@
1
+Imports System
2
+Imports System.IO
3
+Imports System.Net
4
+Imports System.Net.Mail
5
+Imports System.Text
6
+Imports System.Threading.Tasks
7
+Imports System.Windows.Forms
8
+
9
+Public Class SmtpTestForm
10
+    Inherits Form
11
+
12
+    ' UI 控制項宣告
13
+    Private grpServer As GroupBox
14
+    Private lblServer As Label
15
+    Private txtServer As TextBox
16
+    Private lblPort As Label
17
+    Private txtPort As TextBox
18
+    Private chkSSL As CheckBox
19
+    Private chkAuth As CheckBox
20
+
21
+    Private grpAuth As GroupBox
22
+    Private lblUsername As Label
23
+    Private txtUsername As TextBox
24
+    Private lblPassword As Label
25
+    Private txtPassword As TextBox
26
+
27
+    Private grpEmail As GroupBox
28
+    Private lblFrom As Label
29
+    Private txtFrom As TextBox
30
+    Private lblTo As Label
31
+    Private txtTo As TextBox
32
+    Private lblSubject As Label
33
+    Private txtSubject As TextBox
34
+    Private lblBody As Label
35
+    Private txtBody As TextBox
36
+
37
+    Private grpOptions As GroupBox
38
+    Private btnSmtpTest As Button
39
+    Private btnSendTest As Button
40
+    Private btnSaveSettings As Button
41
+    Private btnLoadSettings As Button
42
+
43
+    Private txtLog As TextBox
44
+
45
+    ' 配置文件路徑
46
+    Private ReadOnly ConfigFile As String = Path.Combine(Application.StartupPath, "smtp_config.ini")
47
+
48
+    Public Sub New()
49
+        InitializeComponent00()
50
+        LoadSettings()
51
+    End Sub
52
+
53
+    Private Sub InitializeComponent00()
54
+        ' 設定窗體屬性
55
+        Me.Text = "內部郵件發送測試工具"
56
+        Me.Size = New Size(700, 650)
57
+        Me.StartPosition = FormStartPosition.CenterScreen
58
+        Me.FormBorderStyle = FormBorderStyle.FixedDialog
59
+        Me.MaximizeBox = False
60
+
61
+        ' 伺服器配置區域
62
+        grpServer = New GroupBox()
63
+        grpServer.Text = "SMTP 伺服器設定"
64
+        grpServer.Location = New Point(12, 12)
65
+        grpServer.Size = New Size(320, 140)
66
+
67
+        lblServer = New Label()
68
+        lblServer.Text = "伺服器地址:"
69
+        lblServer.Location = New Point(15, 30)
70
+        lblServer.Size = New Size(100, 20)
71
+
72
+        txtServer = New TextBox()
73
+        txtServer.Location = New Point(120, 30)
74
+        txtServer.Size = New Size(180, 23)
75
+        txtServer.Text = "mail.yourcompany.com"
76
+
77
+        lblPort = New Label()
78
+        lblPort.Text = "伺服器端口:"
79
+        lblPort.Location = New Point(15, 60)
80
+        lblPort.Size = New Size(100, 20)
81
+
82
+        txtPort = New TextBox()
83
+        txtPort.Location = New Point(120, 60)
84
+        txtPort.Size = New Size(180, 23)
85
+        txtPort.Text = "25"
86
+
87
+        chkSSL = New CheckBox()
88
+        chkSSL.Text = "使用 SSL/TLS 加密連接"
89
+        chkSSL.Location = New Point(15, 90)
90
+        chkSSL.Size = New Size(200, 20)
91
+        chkSSL.Checked = False
92
+
93
+        chkAuth = New CheckBox()
94
+        chkAuth.Text = "需要身份認證"
95
+        chkAuth.Location = New Point(15, 110)
96
+        chkAuth.Size = New Size(200, 20)
97
+        chkAuth.Checked = True
98
+        AddHandler chkAuth.CheckedChanged, AddressOf ChkAuth_CheckedChanged
99
+
100
+        grpServer.Controls.Add(lblServer)
101
+        grpServer.Controls.Add(txtServer)
102
+        grpServer.Controls.Add(lblPort)
103
+        grpServer.Controls.Add(txtPort)
104
+        grpServer.Controls.Add(chkSSL)
105
+        grpServer.Controls.Add(chkAuth)
106
+
107
+        ' 認證配置區域
108
+        grpAuth = New GroupBox()
109
+        grpAuth.Text = "認證信息"
110
+        grpAuth.Location = New Point(350, 12)
111
+        grpAuth.Size = New Size(320, 140)
112
+
113
+        lblUsername = New Label()
114
+        lblUsername.Text = "用戶名:"
115
+        lblUsername.Location = New Point(15, 30)
116
+        lblUsername.Size = New Size(100, 20)
117
+
118
+        txtUsername = New TextBox()
119
+        txtUsername.Location = New Point(120, 30)
120
+        txtUsername.Size = New Size(180, 23)
121
+        txtUsername.Text = "user@yourcompany.com"
122
+
123
+        lblPassword = New Label()
124
+        lblPassword.Text = "密碼:"
125
+        lblPassword.Location = New Point(15, 60)
126
+        lblPassword.Size = New Size(100, 20)
127
+
128
+        txtPassword = New TextBox()
129
+        txtPassword.Location = New Point(120, 60)
130
+        txtPassword.Size = New Size(180, 23)
131
+        txtPassword.PasswordChar = "*"c
132
+
133
+        grpAuth.Controls.Add(lblUsername)
134
+        grpAuth.Controls.Add(txtUsername)
135
+        grpAuth.Controls.Add(lblPassword)
136
+        grpAuth.Controls.Add(txtPassword)
137
+
138
+        ' 郵件內容區域
139
+        grpEmail = New GroupBox()
140
+        grpEmail.Text = "郵件內容"
141
+        grpEmail.Location = New Point(12, 160)
142
+        grpEmail.Size = New Size(658, 220)
143
+
144
+        lblFrom = New Label()
145
+        lblFrom.Text = "發件人:"
146
+        lblFrom.Location = New Point(15, 30)
147
+        lblFrom.Size = New Size(100, 20)
148
+
149
+        txtFrom = New TextBox()
150
+        txtFrom.Location = New Point(120, 30)
151
+        txtFrom.Size = New Size(520, 23)
152
+        txtFrom.Text = "alerts@yourcompany.com"
153
+
154
+        lblTo = New Label()
155
+        lblTo.Text = "收件人:"
156
+        lblTo.Location = New Point(15, 60)
157
+        lblTo.Size = New Size(100, 20)
158
+
159
+        txtTo = New TextBox()
160
+        txtTo.Location = New Point(120, 60)
161
+        txtTo.Size = New Size(520, 23)
162
+        txtTo.Text = "recipient@yourcompany.com"
163
+
164
+        lblSubject = New Label()
165
+        lblSubject.Text = "主旨:"
166
+        lblSubject.Location = New Point(15, 90)
167
+        lblSubject.Size = New Size(100, 20)
168
+
169
+        txtSubject = New TextBox()
170
+        txtSubject.Location = New Point(120, 90)
171
+        txtSubject.Size = New Size(520, 23)
172
+        txtSubject.Text = "測試郵件"
173
+
174
+        lblBody = New Label()
175
+        lblBody.Text = "內容:"
176
+        lblBody.Location = New Point(15, 120)
177
+        lblBody.Size = New Size(100, 20)
178
+
179
+        txtBody = New TextBox()
180
+        txtBody.Location = New Point(120, 120)
181
+        txtBody.Size = New Size(520, 80)
182
+        txtBody.Multiline = True
183
+        txtBody.ScrollBars = ScrollBars.Vertical
184
+        txtBody.Text = "這是一封測試郵件,用於驗證 SMTP 功能。" & vbCrLf & vbCrLf & "發送時間: " & DateTime.Now.ToString()
185
+
186
+        grpEmail.Controls.Add(lblFrom)
187
+        grpEmail.Controls.Add(txtFrom)
188
+        grpEmail.Controls.Add(lblTo)
189
+        grpEmail.Controls.Add(txtTo)
190
+        grpEmail.Controls.Add(lblSubject)
191
+        grpEmail.Controls.Add(txtSubject)
192
+        grpEmail.Controls.Add(lblBody)
193
+        grpEmail.Controls.Add(txtBody)
194
+
195
+        ' 操作按鈕區域
196
+        grpOptions = New GroupBox()
197
+        grpOptions.Text = "操作"
198
+        grpOptions.Location = New Point(12, 390)
199
+        grpOptions.Size = New Size(658, 70)
200
+
201
+        btnSmtpTest = New Button()
202
+        btnSmtpTest.Text = "測試 SMTP 連接"
203
+        btnSmtpTest.Location = New Point(15, 25)
204
+        btnSmtpTest.Size = New Size(150, 30)
205
+        AddHandler btnSmtpTest.Click, AddressOf BtnSmtpTest_Click
206
+
207
+        btnSendTest = New Button()
208
+        btnSendTest.Text = "發送測試郵件"
209
+        btnSendTest.Location = New Point(175, 25)
210
+        btnSendTest.Size = New Size(150, 30)
211
+        AddHandler btnSendTest.Click, AddressOf BtnSendTest_Click
212
+
213
+        btnSaveSettings = New Button()
214
+        btnSaveSettings.Text = "保存設定"
215
+        btnSaveSettings.Location = New Point(335, 25)
216
+        btnSaveSettings.Size = New Size(150, 30)
217
+        AddHandler btnSaveSettings.Click, AddressOf BtnSaveSettings_Click
218
+
219
+        btnLoadSettings = New Button()
220
+        btnLoadSettings.Text = "加載設定"
221
+        btnLoadSettings.Location = New Point(495, 25)
222
+        btnLoadSettings.Size = New Size(150, 30)
223
+        AddHandler btnLoadSettings.Click, AddressOf BtnLoadSettings_Click
224
+
225
+        grpOptions.Controls.Add(btnSmtpTest)
226
+        grpOptions.Controls.Add(btnSendTest)
227
+        grpOptions.Controls.Add(btnSaveSettings)
228
+        grpOptions.Controls.Add(btnLoadSettings)
229
+
230
+        ' 日誌區域
231
+        txtLog = New TextBox()
232
+        txtLog.Multiline = True
233
+        txtLog.ScrollBars = ScrollBars.Both
234
+        txtLog.ReadOnly = True
235
+        txtLog.Location = New Point(12, 470)
236
+        txtLog.Size = New Size(658, 130)
237
+        txtLog.BackColor = Color.FromArgb(240, 240, 240)
238
+
239
+        ' 添加控件到窗體
240
+        Me.Controls.Add(grpServer)
241
+        Me.Controls.Add(grpAuth)
242
+        Me.Controls.Add(grpEmail)
243
+        Me.Controls.Add(grpOptions)
244
+        Me.Controls.Add(txtLog)
245
+
246
+        ' 初始化界面狀態
247
+        UpdateAuthUIState()
248
+    End Sub
249
+
250
+    Private Sub ChkAuth_CheckedChanged(sender As Object, e As EventArgs)
251
+        UpdateAuthUIState()
252
+    End Sub
253
+
254
+    Private Sub UpdateAuthUIState()
255
+        ' 根據是否需要認證來啟用/禁用認證信息輸入
256
+        grpAuth.Enabled = chkAuth.Checked
257
+    End Sub
258
+
259
+    Private Sub BtnSmtpTest_Click(sender As Object, e As EventArgs)
260
+        LogMessage("開始測試 SMTP 連接...")
261
+        TestSmtpConnection()
262
+    End Sub
263
+
264
+    Private Async Sub BtnSendTest_Click(sender As Object, e As EventArgs)
265
+        LogMessage("開始發送測試郵件...")
266
+
267
+        ' 更新郵件內容中的時間戳
268
+        If Not txtBody.Text.Contains("發送時間:") Then
269
+            txtBody.Text &= vbCrLf & vbCrLf & "發送時間: "
270
+        End If
271
+
272
+        txtBody.Text = txtBody.Text.Replace(txtBody.Text.Substring(txtBody.Text.IndexOf("發送時間:")),
273
+                                          "發送時間: " & DateTime.Now.ToString())
274
+
275
+        ' 發送測試郵件
276
+        Await SendTestEmailAsync()
277
+    End Sub
278
+
279
+    Private Sub BtnSaveSettings_Click(sender As Object, e As EventArgs)
280
+        SaveSettings()
281
+    End Sub
282
+
283
+    Private Sub BtnLoadSettings_Click(sender As Object, e As EventArgs)
284
+        LoadSettings()
285
+    End Sub
286
+
287
+    Private Sub SaveSettings()
288
+        Try
289
+            Using writer As New StreamWriter(ConfigFile, False)
290
+                writer.WriteLine("Server=" & txtServer.Text)
291
+                writer.WriteLine("Port=" & txtPort.Text)
292
+                writer.WriteLine("SSL=" & chkSSL.Checked.ToString())
293
+                writer.WriteLine("RequireAuth=" & chkAuth.Checked.ToString())
294
+                writer.WriteLine("Username=" & txtUsername.Text)
295
+                ' 注意:出於安全考慮,密碼不會以明文保存
296
+                ' 實際應用中應使用安全的加密方式存儲密碼
297
+                ' 這裡僅為演示,使用簡單的編碼
298
+                Dim encodedPassword As String = Convert.ToBase64String(Encoding.UTF8.GetBytes(txtPassword.Text))
299
+                writer.WriteLine("Password=" & encodedPassword)
300
+                writer.WriteLine("From=" & txtFrom.Text)
301
+                writer.WriteLine("To=" & txtTo.Text)
302
+            End Using
303
+            LogMessage("設定已保存到: " & ConfigFile)
304
+        Catch ex As Exception
305
+            LogMessage("保存設定失敗: " & ex.Message)
306
+        End Try
307
+    End Sub
308
+
309
+    Private Sub LoadSettings()
310
+        If Not File.Exists(ConfigFile) Then
311
+            LogMessage("設定文件不存在,使用默認值")
312
+            Return
313
+        End If
314
+
315
+        Try
316
+            Dim settings As New Dictionary(Of String, String)()
317
+
318
+            Using reader As New StreamReader(ConfigFile)
319
+                While Not reader.EndOfStream
320
+                    Dim line As String = reader.ReadLine()
321
+                    If Not String.IsNullOrEmpty(line) AndAlso line.Contains("=") Then
322
+                        Dim parts As String() = line.Split(New Char() {"="c}, 2)
323
+                        If parts.Length = 2 Then
324
+                            settings(parts(0)) = parts(1)
325
+                        End If
326
+                    End If
327
+                End While
328
+            End Using
329
+
330
+            If settings.ContainsKey("Server") Then txtServer.Text = settings("Server")
331
+            If settings.ContainsKey("Port") Then txtPort.Text = settings("Port")
332
+            If settings.ContainsKey("SSL") Then chkSSL.Checked = Boolean.Parse(settings("SSL"))
333
+            If settings.ContainsKey("RequireAuth") Then chkAuth.Checked = Boolean.Parse(settings("RequireAuth"))
334
+            If settings.ContainsKey("Username") Then txtUsername.Text = settings("Username")
335
+            If settings.ContainsKey("Password") Then
336
+                ' 解碼密碼
337
+                Try
338
+                    Dim decodedBytes As Byte() = Convert.FromBase64String(settings("Password"))
339
+                    txtPassword.Text = Encoding.UTF8.GetString(decodedBytes)
340
+                Catch
341
+                    txtPassword.Text = ""
342
+                End Try
343
+            End If
344
+            If settings.ContainsKey("From") Then txtFrom.Text = settings("From")
345
+            If settings.ContainsKey("To") Then txtTo.Text = settings("To")
346
+
347
+            UpdateAuthUIState()
348
+            LogMessage("設定已從文件加載: " & ConfigFile)
349
+        Catch ex As Exception
350
+            LogMessage("加載設定失敗: " & ex.Message)
351
+        End Try
352
+    End Sub
353
+
354
+    Private Async Sub TestSmtpConnection()
355
+        Dim server As String = txtServer.Text.Trim()
356
+        Dim port As Integer
357
+
358
+        If String.IsNullOrEmpty(server) Then
359
+            LogMessage("錯誤: 請輸入 SMTP 伺服器地址")
360
+            Return
361
+        End If
362
+
363
+        If Not Integer.TryParse(txtPort.Text, port) OrElse port <= 0 OrElse port > 65535 Then
364
+            LogMessage("錯誤: 端口號無效,請輸入 1-65535 之間的數字")
365
+            Return
366
+        End If
367
+
368
+        Try
369
+            ' 首先嘗試 TCP 連接到指定端口
370
+            LogMessage("嘗試連接到 " & server & ":" & port & "...")
371
+
372
+            Await Task.Run(Sub()
373
+                               Try
374
+                                   Using client As New System.Net.Sockets.TcpClient()
375
+                                       ' 嘗試連接,設置 5 秒超時
376
+                                       Dim result As IAsyncResult = client.BeginConnect(server, port, Nothing, Nothing)
377
+                                       Dim success As Boolean = result.AsyncWaitHandle.WaitOne(5000, True)
378
+
379
+                                       If success Then
380
+                                           Invoke(Sub() LogMessage("TCP 連接成功"))
381
+
382
+                                           ' 如果成功連接,建立一個 SMTP 客戶端進行完整測試
383
+                                           Invoke(Sub() LogMessage("嘗試 SMTP 協議測試..."))
384
+
385
+                                           Using smtpClient As New SmtpClient(server, port)
386
+                                               smtpClient.EnableSsl = chkSSL.Checked
387
+                                               smtpClient.Timeout = 10000 ' 10 秒超時
388
+
389
+                                               If chkAuth.Checked Then
390
+                                                   smtpClient.Credentials = New NetworkCredential(txtUsername.Text, txtPassword.Text)
391
+                                               End If
392
+
393
+                                               ' 建立一個空郵件用於測試,不實際發送
394
+                                               Dim testMessage As New MailMessage()
395
+                                               testMessage.From = New MailAddress(txtFrom.Text)
396
+                                               testMessage.Subject = "測試連接 (不會發送)"
397
+
398
+                                               ' 不實際發送,只測試連接
399
+                                               ' 這裡我們不調用 Send,而是只測試當前連接狀態
400
+                                           End Using
401
+
402
+                                           Invoke(Sub() LogMessage("SMTP 連接測試成功!伺服器連接正常。"))
403
+                                       Else
404
+                                           Invoke(Sub() LogMessage("錯誤: 無法連接到伺服器,連接超時"))
405
+                                           client.Close()
406
+                                       End If
407
+                                   End Using
408
+                               Catch ex As Exception
409
+                                   Invoke(Sub() LogMessage("連接測試失敗: " & ex.Message))
410
+                               End Try
411
+                           End Sub)
412
+        Catch ex As Exception
413
+            LogMessage("測試過程出錯: " & ex.Message)
414
+        End Try
415
+    End Sub
416
+
417
+    Private Async Function SendTestEmailAsync() As Task
418
+        Dim server As String = txtServer.Text.Trim()
419
+        Dim port As Integer
420
+
421
+        If String.IsNullOrEmpty(server) Then
422
+            LogMessage("錯誤: 請輸入 SMTP 伺服器地址")
423
+            Return
424
+        End If
425
+
426
+        If Not Integer.TryParse(txtPort.Text, port) OrElse port <= 0 OrElse port > 65535 Then
427
+            LogMessage("錯誤: 端口號無效,請輸入 1-65535 之間的數字")
428
+            Return
429
+        End If
430
+
431
+        If String.IsNullOrEmpty(txtFrom.Text) Then
432
+            LogMessage("錯誤: 請輸入發件人郵箱")
433
+            Return
434
+        End If
435
+
436
+        If String.IsNullOrEmpty(txtTo.Text) Then
437
+            LogMessage("錯誤: 請輸入收件人郵箱")
438
+            Return
439
+        End If
440
+
441
+        Try
442
+            LogMessage("準備發送郵件...")
443
+
444
+            ' 使用 Task.Run 避免阻塞 UI 線程
445
+            Await Task.Run(Sub()
446
+                               Try
447
+                                   Invoke(Sub() LogMessage("配置 SMTP 客戶端..."))
448
+
449
+                                   ' 配置 SMTP 客戶端
450
+                                   Using smtpClient As New SmtpClient(server, port)
451
+                                       Invoke(Sub() LogMessage("設置 SMTP 參數..."))
452
+
453
+                                       smtpClient.EnableSsl = chkSSL.Checked
454
+                                       smtpClient.Timeout = 30000 ' 30 秒超時
455
+
456
+                                       If chkAuth.Checked Then
457
+                                           Invoke(Sub() LogMessage("使用認證..."))
458
+                                           smtpClient.Credentials = New NetworkCredential(txtUsername.Text, txtPassword.Text)
459
+                                       End If
460
+
461
+                                       ' 創建郵件
462
+                                       Invoke(Sub() LogMessage("創建郵件內容..."))
463
+
464
+                                       Using message As New MailMessage()
465
+                                           message.From = New MailAddress(txtFrom.Text)
466
+
467
+                                           ' 處理多個收件人(以逗號或分號分隔)
468
+                                           Dim toAddresses As String() = txtTo.Text.Split(New Char() {","c, ";"c}, StringSplitOptions.RemoveEmptyEntries)
469
+                                           For Each address As String In toAddresses
470
+                                               message.To.Add(address.Trim())
471
+                                           Next
472
+
473
+                                           message.Subject = txtSubject.Text
474
+                                           message.Body = txtBody.Text
475
+                                           message.BodyEncoding = Encoding.UTF8
476
+                                           message.IsBodyHtml = False
477
+
478
+                                           ' 詳細日誌記錄
479
+                                           Invoke(Sub() LogMessage("發送至: " & String.Join(", ", toAddresses)))
480
+                                           Invoke(Sub() LogMessage("主旨: " & txtSubject.Text))
481
+                                           Invoke(Sub() LogMessage("正在發送郵件..."))
482
+
483
+                                           ' 發送郵件
484
+                                           smtpClient.Send(message)
485
+
486
+                                           Invoke(Sub() LogMessage("郵件已成功發送!"))
487
+                                       End Using
488
+                                   End Using
489
+                               Catch ex As Exception
490
+                                   Invoke(Sub() LogMessageWithDetails("發送郵件失敗", ex))
491
+                               End Try
492
+                           End Sub)
493
+        Catch ex As Exception
494
+            LogMessage("發送過程出錯: " & ex.Message)
495
+        End Try
496
+    End Function
497
+
498
+    Private Sub LogMessage(message As String)
499
+        ' 確保在 UI 線程上執行
500
+        If txtLog.InvokeRequired Then
501
+            txtLog.Invoke(New Action(Of String)(AddressOf LogMessage), message)
502
+            Return
503
+        End If
504
+
505
+        ' 添加時間戳並顯示消息
506
+        Dim logEntry As String = DateTime.Now.ToString("[HH:mm:ss] ") & message
507
+        txtLog.AppendText(logEntry & Environment.NewLine)
508
+
509
+        ' 滾動到底部
510
+        txtLog.SelectionStart = txtLog.Text.Length
511
+        txtLog.ScrollToCaret()
512
+    End Sub
513
+
514
+    Private Sub LogMessageWithDetails(message As String, ex As Exception)
515
+        LogMessage(message & ": " & ex.Message)
516
+
517
+        ' 添加詳細的異常信息,包括內部異常
518
+        If ex.InnerException IsNot Nothing Then
519
+            LogMessage("內部錯誤: " & ex.InnerException.Message)
520
+        End If
521
+
522
+        ' 添加堆棧跟踪
523
+        LogMessage("詳細信息: " & ex.ToString())
524
+    End Sub
525
+
526
+    Private Sub SaveDebugEmail(subject As String, body As String, recipients As String)
527
+        Try
528
+            ' 創建調試目錄
529
+            Dim debugDir As String = Path.Combine(Application.StartupPath, "debug_emails")
530
+            If Not Directory.Exists(debugDir) Then
531
+                Directory.CreateDirectory(debugDir)
532
+            End If
533
+
534
+            ' 創建唯一文件名
535
+            Dim filename As String = "email_" & DateTime.Now.ToString("yyyyMMdd_HHmmss") & ".txt"
536
+            Dim filepath As String = Path.Combine(debugDir, filename)
537
+
538
+            ' 保存郵件內容
539
+            Using writer As New StreamWriter(filepath, False, Encoding.UTF8)
540
+                writer.WriteLine("Date: " & DateTime.Now.ToString())
541
+                writer.WriteLine("From: " & txtFrom.Text)
542
+                writer.WriteLine("To: " & recipients)
543
+                writer.WriteLine("Subject: " & subject)
544
+                writer.WriteLine("-------------------------")
545
+                writer.WriteLine(body)
546
+            End Using
547
+
548
+            LogMessage("已保存調試郵件到: " & filepath)
549
+        Catch ex As Exception
550
+            LogMessage("保存調試郵件失敗: " & ex.Message)
551
+        End Try
552
+    End Sub
553
+End Class
554
+
555
+Module Program
556
+    Sub Main()
557
+        Application.EnableVisualStyles()
558
+        Application.SetCompatibleTextRenderingDefault(False)
559
+        Application.Run(New SmtpTestForm())
560
+    End Sub
561
+End Module

+ 130
- 0
SmtpTestForm_ca/SmtpTestForm_ca.vbproj ファイルの表示

@@ -0,0 +1,130 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4
+  <PropertyGroup>
5
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7
+    <ProjectGuid>{592EBADA-85EC-4658-8F4B-F8819936B798}</ProjectGuid>
8
+    <OutputType>WinExe</OutputType>
9
+    <StartupObject>SmtpTestForm_ca.My.MyApplication</StartupObject>
10
+    <RootNamespace>SmtpTestForm_ca</RootNamespace>
11
+    <AssemblyName>SmtpTestForm_ca</AssemblyName>
12
+    <FileAlignment>512</FileAlignment>
13
+    <MyType>WindowsForms</MyType>
14
+    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
15
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16
+    <Deterministic>true</Deterministic>
17
+  </PropertyGroup>
18
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19
+    <PlatformTarget>AnyCPU</PlatformTarget>
20
+    <DebugSymbols>true</DebugSymbols>
21
+    <DebugType>full</DebugType>
22
+    <DefineDebug>true</DefineDebug>
23
+    <DefineTrace>true</DefineTrace>
24
+    <OutputPath>bin\Debug\</OutputPath>
25
+    <DocumentationFile>SmtpTestForm_ca.xml</DocumentationFile>
26
+    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
27
+  </PropertyGroup>
28
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29
+    <PlatformTarget>AnyCPU</PlatformTarget>
30
+    <DebugType>pdbonly</DebugType>
31
+    <DefineDebug>false</DefineDebug>
32
+    <DefineTrace>true</DefineTrace>
33
+    <Optimize>true</Optimize>
34
+    <OutputPath>bin\Release\</OutputPath>
35
+    <DocumentationFile>SmtpTestForm_ca.xml</DocumentationFile>
36
+    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
37
+  </PropertyGroup>
38
+  <PropertyGroup>
39
+    <OptionExplicit>On</OptionExplicit>
40
+  </PropertyGroup>
41
+  <PropertyGroup>
42
+    <OptionCompare>Binary</OptionCompare>
43
+  </PropertyGroup>
44
+  <PropertyGroup>
45
+    <OptionStrict>Off</OptionStrict>
46
+  </PropertyGroup>
47
+  <PropertyGroup>
48
+    <OptionInfer>On</OptionInfer>
49
+  </PropertyGroup>
50
+  <PropertyGroup>
51
+    <ApplicationIcon>n4cbk-unm1w-001.ico</ApplicationIcon>
52
+  </PropertyGroup>
53
+  <ItemGroup>
54
+    <Reference Include="System" />
55
+    <Reference Include="System.Data" />
56
+    <Reference Include="System.Deployment" />
57
+    <Reference Include="System.Drawing" />
58
+    <Reference Include="System.Windows.Forms" />
59
+    <Reference Include="System.Xml" />
60
+    <Reference Include="System.Core" />
61
+    <Reference Include="System.Xml.Linq" />
62
+    <Reference Include="System.Data.DataSetExtensions" />
63
+    <Reference Include="System.Net.Http" />
64
+  </ItemGroup>
65
+  <ItemGroup>
66
+    <Import Include="Microsoft.VisualBasic" />
67
+    <Import Include="System" />
68
+    <Import Include="System.Collections" />
69
+    <Import Include="System.Collections.Generic" />
70
+    <Import Include="System.Data" />
71
+    <Import Include="System.Drawing" />
72
+    <Import Include="System.Diagnostics" />
73
+    <Import Include="System.Windows.Forms" />
74
+    <Import Include="System.Linq" />
75
+    <Import Include="System.Xml.Linq" />
76
+    <Import Include="System.Threading.Tasks" />
77
+  </ItemGroup>
78
+  <ItemGroup>
79
+    <Compile Include="SmtpTestForm.vb">
80
+      <SubType>Form</SubType>
81
+    </Compile>
82
+    <Compile Include="SmtpTestForm.Designer.vb">
83
+      <DependentUpon>SmtpTestForm.vb</DependentUpon>
84
+      <SubType>Form</SubType>
85
+    </Compile>
86
+    <Compile Include="My Project\AssemblyInfo.vb" />
87
+    <Compile Include="My Project\Application.Designer.vb">
88
+      <AutoGen>True</AutoGen>
89
+      <DependentUpon>Application.myapp</DependentUpon>
90
+      <DesignTime>True</DesignTime>
91
+    </Compile>
92
+    <Compile Include="My Project\Resources.Designer.vb">
93
+      <AutoGen>True</AutoGen>
94
+      <DesignTime>True</DesignTime>
95
+      <DependentUpon>Resources.resx</DependentUpon>
96
+    </Compile>
97
+    <Compile Include="My Project\Settings.Designer.vb">
98
+      <AutoGen>True</AutoGen>
99
+      <DependentUpon>Settings.settings</DependentUpon>
100
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
101
+    </Compile>
102
+  </ItemGroup>
103
+  <ItemGroup>
104
+    <EmbeddedResource Include="SmtpTestForm.resx">
105
+      <DependentUpon>SmtpTestForm.vb</DependentUpon>
106
+    </EmbeddedResource>
107
+    <EmbeddedResource Include="My Project\Resources.resx">
108
+      <Generator>VbMyResourcesResXFileCodeGenerator</Generator>
109
+      <LastGenOutput>Resources.Designer.vb</LastGenOutput>
110
+      <CustomToolNamespace>My.Resources</CustomToolNamespace>
111
+      <SubType>Designer</SubType>
112
+    </EmbeddedResource>
113
+  </ItemGroup>
114
+  <ItemGroup>
115
+    <None Include="My Project\Application.myapp">
116
+      <Generator>MyApplicationCodeGenerator</Generator>
117
+      <LastGenOutput>Application.Designer.vb</LastGenOutput>
118
+    </None>
119
+    <None Include="My Project\Settings.settings">
120
+      <Generator>SettingsSingleFileGenerator</Generator>
121
+      <CustomToolNamespace>My</CustomToolNamespace>
122
+      <LastGenOutput>Settings.Designer.vb</LastGenOutput>
123
+    </None>
124
+    <None Include="App.config" />
125
+  </ItemGroup>
126
+  <ItemGroup>
127
+    <Content Include="n4cbk-unm1w-001.ico" />
128
+  </ItemGroup>
129
+  <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
130
+</Project>

バイナリ
SmtpTestForm_ca/bin/Debug/SmtpTestForm_ca.exe ファイルの表示


+ 6
- 0
SmtpTestForm_ca/bin/Debug/SmtpTestForm_ca.exe.config ファイルの表示

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="utf-8" ?>
2
+<configuration>
3
+    <startup>
4
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5
+    </startup>
6
+</configuration>

バイナリ
SmtpTestForm_ca/bin/Debug/SmtpTestForm_ca.pdb ファイルの表示


+ 26
- 0
SmtpTestForm_ca/bin/Debug/SmtpTestForm_ca.xml ファイルの表示

@@ -0,0 +1,26 @@
1
+<?xml version="1.0"?>
2
+<doc>
3
+<assembly>
4
+<name>
5
+SmtpTestForm_ca
6
+</name>
7
+</assembly>
8
+<members>
9
+<member name="T:SmtpTestForm_ca.My.Resources.Resources">
10
+<summary>
11
+  A strongly-typed resource class, for looking up localized strings, etc.
12
+</summary>
13
+</member>
14
+<member name="P:SmtpTestForm_ca.My.Resources.Resources.ResourceManager">
15
+<summary>
16
+  Returns the cached ResourceManager instance used by this class.
17
+</summary>
18
+</member>
19
+<member name="P:SmtpTestForm_ca.My.Resources.Resources.Culture">
20
+<summary>
21
+  Overrides the current thread's CurrentUICulture property for all
22
+  resource lookups using this strongly typed resource class.
23
+</summary>
24
+</member>
25
+</members>
26
+</doc>

+ 8
- 0
SmtpTestForm_ca/bin/Debug/smtp_config.ini ファイルの表示

@@ -0,0 +1,8 @@
1
+Server=127.0.0.1
2
+Port=25
3
+SSL=False
4
+RequireAuth=True
5
+Username=gordon@test.local
6
+Password=NjU0MzIx
7
+From=gordon@test.local
8
+To=mars@test.local

バイナリ
SmtpTestForm_ca/n4cbk-unm1w-001.ico ファイルの表示


+ 7
- 0
SmtpTestForm_ca/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.vb ファイルの表示

@@ -0,0 +1,7 @@
1
+' <autogenerated/>
2
+            Option Strict Off
3
+            Option Explicit On
4
+
5
+            Imports System
6
+            Imports System.Reflection
7
+            <Assembly: Global.System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName:=".NET Framework 4.8")>

バイナリ
SmtpTestForm_ca/obj/Debug/DesignTimeResolveAssemblyReferences.cache ファイルの表示


バイナリ
SmtpTestForm_ca/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache ファイルの表示


バイナリ
SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.Resources.resources ファイルの表示


バイナリ
SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.SmtpTestForm.resources ファイルの表示


バイナリ
SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.exe ファイルの表示


バイナリ
SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.pdb ファイルの表示


バイナリ
SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.vbproj.AssemblyReference.cache ファイルの表示


+ 1
- 0
SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.vbproj.CoreCompileInputs.cache ファイルの表示

@@ -0,0 +1 @@
1
+923cf896732f6322ba18656b535d81d4c3d344f17a0791b701ec3afb612e6855

+ 12
- 0
SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.vbproj.FileListAbsolute.txt ファイルの表示

@@ -0,0 +1,12 @@
1
+D:\Project\SmtpTestForm_ca\SmtpTestForm_ca\obj\Debug\SmtpTestForm_ca.vbproj.AssemblyReference.cache
2
+D:\Project\SmtpTestForm_ca\SmtpTestForm_ca\obj\Debug\SmtpTestForm_ca.SmtpTestForm.resources
3
+D:\Project\SmtpTestForm_ca\SmtpTestForm_ca\obj\Debug\SmtpTestForm_ca.Resources.resources
4
+D:\Project\SmtpTestForm_ca\SmtpTestForm_ca\obj\Debug\SmtpTestForm_ca.vbproj.GenerateResource.cache
5
+D:\Project\SmtpTestForm_ca\SmtpTestForm_ca\obj\Debug\SmtpTestForm_ca.vbproj.CoreCompileInputs.cache
6
+D:\Project\SmtpTestForm_ca\SmtpTestForm_ca\bin\Debug\SmtpTestForm_ca.exe.config
7
+D:\Project\SmtpTestForm_ca\SmtpTestForm_ca\bin\Debug\SmtpTestForm_ca.exe
8
+D:\Project\SmtpTestForm_ca\SmtpTestForm_ca\bin\Debug\SmtpTestForm_ca.pdb
9
+D:\Project\SmtpTestForm_ca\SmtpTestForm_ca\bin\Debug\SmtpTestForm_ca.xml
10
+D:\Project\SmtpTestForm_ca\SmtpTestForm_ca\obj\Debug\SmtpTestForm_ca.exe
11
+D:\Project\SmtpTestForm_ca\SmtpTestForm_ca\obj\Debug\SmtpTestForm_ca.xml
12
+D:\Project\SmtpTestForm_ca\SmtpTestForm_ca\obj\Debug\SmtpTestForm_ca.pdb

バイナリ
SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.vbproj.GenerateResource.cache ファイルの表示


+ 26
- 0
SmtpTestForm_ca/obj/Debug/SmtpTestForm_ca.xml ファイルの表示

@@ -0,0 +1,26 @@
1
+<?xml version="1.0"?>
2
+<doc>
3
+<assembly>
4
+<name>
5
+SmtpTestForm_ca
6
+</name>
7
+</assembly>
8
+<members>
9
+<member name="T:SmtpTestForm_ca.My.Resources.Resources">
10
+<summary>
11
+  A strongly-typed resource class, for looking up localized strings, etc.
12
+</summary>
13
+</member>
14
+<member name="P:SmtpTestForm_ca.My.Resources.Resources.ResourceManager">
15
+<summary>
16
+  Returns the cached ResourceManager instance used by this class.
17
+</summary>
18
+</member>
19
+<member name="P:SmtpTestForm_ca.My.Resources.Resources.Culture">
20
+<summary>
21
+  Overrides the current thread's CurrentUICulture property for all
22
+  resource lookups using this strongly typed resource class.
23
+</summary>
24
+</member>
25
+</members>
26
+</doc>

バイナリ
SmtpTestForm_ca/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll ファイルの表示


バイナリ
SmtpTestForm_ca/pic/Gemini_Generated_Image_SMTP1.jpg ファイルの表示


バイナリ
SmtpTestForm_ca/pic/n4cbk-unm1w-001.ico ファイルの表示


読み込み中…
キャンセル
保存