📄 project1.frm
字号:
VERSION 5.00
Object = "{20C62CAE-15DA-101B-B9A8-444553540000}#1.1#0"; "MSMAPI32.OCX"
Begin VB.Form Form2
Caption = "用mapi发送电子邮件"
ClientHeight = 5070
ClientLeft = 60
ClientTop = 345
ClientWidth = 7215
LinkTopic = "Form1"
ScaleHeight = 5070
ScaleWidth = 7215
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "保存收件人地址"
Height = 375
Left = 3510
TabIndex = 9
Top = 4560
Width = 1575
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1380
TabIndex = 8
Top = 420
Width = 5295
End
Begin VB.CommandButton Command3
Caption = "退 出"
Height = 375
Left = 5070
TabIndex = 6
Top = 4560
Width = 1575
End
Begin VB.CommandButton Command1
Caption = "发 送"
Height = 375
Left = 1920
TabIndex = 5
Top = 4560
Width = 1575
End
Begin VB.TextBox text1
Height = 315
Index = 0
Left = 1380
TabIndex = 4
Top = 870
Width = 5235
End
Begin VB.TextBox text1
Height = 2595
Index = 1
Left = 1380
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
Top = 1380
Width = 5235
End
Begin MSMAPI.MAPISession MAPISession1
Left = 150
Top = 2190
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DownloadMail = -1 'True
LogonUI = -1 'True
NewSession = 0 'False
End
Begin MSMAPI.MAPIMessages MAPIMessages1
Left = 180
Top = 2940
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
AddressEditFieldCount= 1
AddressModifiable= 0 'False
AddressResolveUI= 0 'False
FetchSorted = 0 'False
FetchUnreadOnly = 0 'False
End
Begin VB.Label Label4
Caption = "Label4"
Height = 435
Left = 1380
TabIndex = 7
Top = 4050
Width = 5205
End
Begin VB.Label Label2
Caption = "主题:"
Height = 255
Left = 540
TabIndex = 3
Top = 930
Width = 735
End
Begin VB.Label Label3
Caption = "内容:"
Height = 255
Left = 510
TabIndex = 1
Top = 1350
Width = 735
End
Begin VB.Label Label1
Caption = "收件人:"
Height = 255
Left = 540
TabIndex = 0
Top = 450
Width = 735
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim mydb As Database
Dim myrs As Recordset
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
text1(0).SetFocus
End If
End Sub
Private Sub Command2_Click()
Set mydb = OpenDatabase(App.Path & "\myemail.mdb")
Set myrs = mydb.OpenRecordset("email", dbOpenTable)
myrs.AddNew
myrs.Fields(0) = Combo1.Text
myrs.Update
myrs.Close
mydb.Close
End Sub
Private Sub Form_Activate()
Combo1.SetFocus
End Sub
Private Sub Form_Load()
On Error Resume Next
MAPISession1.SignOn '建立一个邮件会话
Set mydb = OpenDatabase(App.Path & "\myemail.mdb")
Set myrs = mydb.OpenRecordset("email", dbOpenTable)
myrs.MoveLast
myrs.MoveFirst
numcount = myrs.Fields.Count
For i = 0 To myrs.RecordCount - 1
Combo1.AddItem (myrs.Fields(0))
myrs.MoveNext
Next i
myrs.Close
mydb.Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
MAPISession1.SignOff
End Sub
Private Sub Command1_Click()
MAPIMessages1.MsgIndex = -1
MAPIMessages1.RecipDisplayName = Combo1.Text
MAPIMessages1.MsgSubject = text1(0).Text
MAPIMessages1.MsgNoteText = text1(1).Text
MAPIMessages1.SessionID = MAPISession1.SessionID
MAPIMessages1.Send
Label4.Caption = "发送邮件成功!"
End Sub
Private Sub text1_Change(Index As Integer)
Label4.Caption = ""
End Sub
Private Sub text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
Select Case Index
Case 0
If KeyCode = vbKeyReturn Then text1(1).SetFocus
If KeyCode = vbKeyUp Then Combo1.SetFocus
Case 1
If KeyCode = vbKeyReturn Then Command1.SetFocus
If KeyCode = vbKeyUp Then text1(0).SetFocus
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -