📄 main.frm
字号:
VERSION 5.00
Object = "{20C62CAE-15DA-101B-B9A8-444553540000}#1.1#0"; "MSMAPI32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.MDIForm Main
BackColor = &H8000000C&
Caption = "收发邮件程序"
ClientHeight = 5265
ClientLeft = 165
ClientTop = 735
ClientWidth = 7560
LinkTopic = "MDIForm1"
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Interval = 1000
Left = 6840
Top = 1200
End
Begin MSComDlg.CommonDialog CMDialog1
Left = 6120
Top = 1080
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin MSComctlLib.StatusBar Statusbar1
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 1
Top = 4890
Width = 7560
_ExtentX = 13335
_ExtentY = 661
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 2
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
AutoSize = 1
Object.Width = 10266
EndProperty
BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Alignment = 2
AutoSize = 2
EndProperty
EndProperty
End
Begin MSComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 570
Left = 0
TabIndex = 0
Top = 0
Width = 7560
_ExtentX = 13335
_ExtentY = 1005
ButtonWidth = 1138
ButtonHeight = 953
Wrappable = 0 'False
Appearance = 1
Style = 1
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 18
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "登录"
Key = "Login"
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "写信"
Key = "Compose"
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "收信"
Key = "Fetch"
EndProperty
BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "回复"
Key = "Reply"
EndProperty
BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "发送"
Key = "Forward"
EndProperty
BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "删除"
Key = "Delete"
EndProperty
BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "前一封"
Key = "Previous1"
EndProperty
BeginProperty Button14 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button15 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "下一封"
Key = "Next1"
EndProperty
BeginProperty Button16 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button17 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "退出"
Key = "Exit1"
EndProperty
BeginProperty Button18 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
EndProperty
BorderStyle = 1
End
Begin MSMAPI.MAPISession MAPISess
Left = 5400
Top = 1080
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DownloadMail = -1 'True
LogonUI = -1 'True
NewSession = 0 'False
End
Begin MSMAPI.MAPIMessages MAPIMess
Left = 4680
Top = 1080
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
AddressEditFieldCount= 1
AddressModifiable= 0 'False
AddressResolveUI= 0 'False
FetchSorted = 0 'False
FetchUnreadOnly = 0 'False
End
Begin VB.Menu file
Caption = "文件(&F)"
Begin VB.Menu Logon
Caption = "登录"
End
Begin VB.Menu Logoff
Caption = "注销"
End
Begin VB.Menu PrintMessage
Caption = "打印"
End
Begin VB.Menu Exit
Caption = "退出"
End
End
Begin VB.Menu Option
Caption = "选项(&O)"
Begin VB.Menu PrSetup
Caption = "打印设置"
End
Begin VB.Menu FontScreen
Caption = "窗体字体设置"
End
Begin VB.Menu FontPrt
Caption = "打印字体设置"
End
End
Begin VB.Menu Address
Caption = "通讯簿(&B)"
Begin VB.Menu ShowAB
Caption = "显示通讯簿"
End
End
Begin VB.Menu Window
Caption = "窗口(&W)"
Begin VB.Menu Wa
Caption = "层叠"
Index = 0
End
Begin VB.Menu Wa
Caption = "水平平铺"
Index = 1
End
Begin VB.Menu Wa
Caption = "垂直平铺"
Index = 2
End
Begin VB.Menu Wa
Caption = "排列图标"
Index = 3
End
End
End
Attribute VB_Name = "Main"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub MDIForm_Load()
'进入程序,初始化各菜单,按扭的可用状态
Logoff.Enabled = False
Statusbar1.Panels(2) = Time$
Statusbar1.Panels(1) = "离线状态"
SendWithMapi = True
ShowAB.Enabled = False
Main.Toolbar1.Buttons("Compose").Enabled = False
Main.Toolbar1.Buttons("Fetch").Enabled = False
Main.Toolbar1.Buttons("Reply").Enabled = False
Main.Toolbar1.Buttons("Forward").Enabled = False
Main.Toolbar1.Buttons("Delete").Enabled = False
Main.Toolbar1.Buttons("Previous1").Enabled = False
Main.Toolbar1.Buttons("Next1").Enabled = False
Main.PrintMessage.Enabled = False
Main.MAPISess.LogonUI = True
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error Resume Next
Select Case Button.Key
Case "Login"
Call Logon_Click
Case "Fetch"
Call Mfetch_Click
Case "Compose"
Call Mcompose_Click
Case "Reply"
Call Mreply_Click
Case "Forward"
Call Mforward_Click
Case "Exit1"
Call Exit_Click
Case "Previous1"
'查看前一封邮件
If Form1.Mlist.ListCount <> 0 Then
Form1.Mlist.ItemData(Form1.Mlist.ListIndex) = False
Form1.Mlist.ListIndex = Form1.Mlist.ListIndex - 1
End If
Call ViewNextMsg
Case "Next1"
'查看下一封邮件
If Form1.Mlist.ListIndex <> Form1.Mlist.ListCount - 1 Then
Form1.Mlist.ItemData(Form1.Mlist.ListIndex) = False
Form1.Mlist.ListIndex = Form1.Mlist.ListIndex + 1
End If
Call ViewNextMsg
Case "Delete"
'删除当前的邮件
If TypeOf Main.ActiveForm Is Form2 Then
Call DeleteMessage
ElseIf TypeOf Main.ActiveForm Is Form1 Then
Main.MAPIMess.MsgIndex = Form1.Mlist.ListIndex
Call DeleteMessage
End If
End Select
End Sub
Private Sub EditDelete_Click()
'删除邮件
On Error GoTo trap
If TypeOf Main.ActiveForm Is Form1 Then
Main.MAPIMess.MsgIndex = Form1.Mlist.ListIndex
Call DeleteMessage
End If
trap:
Exit Sub
End Sub
Private Sub Exit_Click()
'退出功能,如果对话未关闭,则调用logoff_Click关闭邮件对话
If MAPISess.SessionID <> 0 Then
Call Logoff_Click
End If
End
End Sub
Private Sub FontPrt_Click()
'打印字体设置
On Error Resume Next
CMDialog1.Flags = 1
CMDialog1.FontName = Printer.FontName
CMDialog1.FontSize = Printer.FontSize
CMDialog1.FontBold = Printer.FontBold
CMDialog1.FontItalic = Printer.FontItalic
CMDialog1.ShowFont
If Err = 0 Then
Printer.FontName = CMDialog1.FontName
Printer.FontSize = CMDialog1.FontSize
Printer.FontBold = CMDialog1.FontBold
Printer.FontItalic = CMDialog1.FontItalic
End If
End Sub
Private Sub FontScreen_Click()
'活动窗体中具有输入焦点控件的字体设置
On Error Resume Next
CMDialog1.Flags = 1
CMDialog1.FontName = Main.ActiveForm.ActiveControl.FontName
CMDialog1.FontSize = Main.ActiveForm.ActiveControl.FontSize
CMDialog1.FontBold = Main.ActiveForm.ActiveControl.FontBold
CMDialog1.FontItalic = Main.ActiveForm.ActiveControl.FontItalic
CMDialog1.ShowFont
If Err = 0 Then
Main.ActiveForm.ActiveControl.FontName = CMDialog1.FontName
Main.ActiveForm.ActiveControl.FontSize = CMDialog1.FontSize
Main.ActiveForm.ActiveControl.FontBold = CMDialog1.FontBold
Main.ActiveForm.ActiveControl.FontItalic = CMDialog1.FontItalic
End If
End Sub
Private Sub Logoff_Click()
'关闭邮件对话,注销用户
Call LogOffUser
End Sub
Private Sub Logon_Click()
'登录
On Error Resume Next
'打开邮件对话
MAPISess.Action = 1
If Err <> 0 Then
MsgBox "登录失败!!!" + Error$
Else
Screen.MousePointer = 11
MAPIMess.SessionID = MAPISess.SessionID
'取得邮箱中邮件的数量
GetMessageCount
Screen.MousePointer = 11
'将邮件的信息装载到邮件列表窗体中的列表框
Call LoadList(MAPIMess)
Screen.MousePointer = 0
'设置各个按扭及菜单的可用状态
Logon.Enabled = False
Logoff.Enabled = True
ShowAB.Enabled = True
Main.Toolbar1.Buttons("Compose").Enabled = True
Main.Toolbar1.Buttons("Fetch").Enabled = True
Main.Toolbar1.Buttons("ReplyAll").Enabled = True
Main.Toolbar1.Buttons("Reply").Enabled = True
Main.Toolbar1.Buttons("Forward").Enabled = True
Main.Toolbar1.Buttons("Delete").Enabled = True
Main.Toolbar1.Buttons("Previous1").Enabled = False
Main.Toolbar1.Buttons("Next1").Enabled = True
Main.PrintMessage.Enabled = True
End If
End Sub
Private Sub MailOpts_Click()
'调用收发邮件设置对话框
OptionType = conOptionGeneral
MailOptFrm.Show
End Sub
Private Sub Mcompose_Click()
'撰写新邮件
Main.MAPIMess.Action = 6
'使用设计的窗体Form3撰写及发送电子邮件
Call LoadMessage(-1, Form3)
End Sub
Private Sub Mfetch_Click()
'读取邮件
Main.MAPIMess.Action = 1
'取得邮箱中邮件的数量
GetMessageCount
'将邮件信息装载到邮件列表窗体中
Call LoadList(MAPIMess)
End Sub
Private Sub Mforward_Click()
'转发邮件
'取得邮件的正文及邮件头
svNote = Main.MAPIMess.MsgNoteText
svNote = GetHeader(Main.MAPIMess) + svNote
'发送
Main.MAPIMess.Action = 9
Main.MAPIMess.MsgNoteText = svNote
If SendWithMapi Then
'使用MAPI对话框撰写及转发电子邮件
Main.MAPIMess.Action = vbMessageSenddlg
Else
'使用设计的窗体Form3撰写及转送电子邮件
Call LoadMessage(-1, Form3)
End If
End Sub
Private Sub Mreply_Click()
'回复邮件
'取得邮件的正文及邮件头
svNote = Main.MAPIMess.MsgNoteText
svNote = GetHeader(Main.MAPIMess) + svNote
'回复
Main.MAPIMess.Action = 7
Main.MAPIMess.MsgNoteText = svNote
If SendWithMapi Then
'使用MAPI对话框撰写及回复电子邮件
Main.MAPIMess.Action = vbMessageSenddlg
Else
'使用设计的窗体Form3撰写及回复电子邮件
Call LoadMessage(-1, Form3)
End If
End Sub
Private Sub Mreplyall_Click()
End Sub
Private Sub PrintMessage_Click()
'打印邮件
Call Printmail
End Sub
Private Sub PrSetup_Click()
'打印机设置
On Error Resume Next
CMDialog1.Flags = &H40
CMDialog1.ShowPrinter
End Sub
Private Sub ShowAB_Click()
'显示地址簿
On Error Resume Next
Main.MAPIMess.Action = vbMessageShowADBook
If Err Then
If errr <> 32001 Then
MsgBox "error:" + Error$ + "occured trying to show the address book"
End If
Else
'更新收信人地址
If TypeOf Main.ActiveForm Is Form3 Then
Call UpdateRecips(Main.ActiveForm)
End If
End If
End Sub
Private Sub Timer1_Timer()
Statusbar1.Panels(2) = Time$
End Sub
Private Sub Wa_Click(Index As Integer)
'排列子窗体
Main.Arrange Index
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -