?? module1.bas
字號:
Public Sub LoadList(mailctl As Control)
'將郵件的信息裝載到郵件列表窗體中的列表框
Form1.Mlist.Clear
UnRead = 0
startindex = 0
For i = 0 To mailctl.MsgCount - 1
mailctl.MsgIndex = i
If Not mailctl.MsgRead Then
'在尚未閱讀過的郵件之前用“*”表示(conUnreadMessage="*")
a$ = conUnreadMessage + ""
If UnRead = 0 Then
'標識第一封沒有閱讀過的郵件的位置
startindex = i
End If
'UnRead為計算沒有閱讀過的郵件的數量
UnRead = UnRead + 1
Else
a$ = " "
End If
'取得當前索引消息的原始發件人的名字
a$ = a$ + Mid$(Format$(mailctl.MsgOrigDisplayName, "!" + String$(10, "@")), 1, 10)
If mailctl.MsgSubject <> "" Then
'取得當前索引消息的主題
b$ = Mid$(Format$(mailctl.MsgSubject, "!" + String$(35, "@")), 1, 35)
Else
b$ = String$(30, "")
End If
'取得當前消息的接收時間
c$ = Mid$(Format$(DateFromMapiDate(mailctl.MsgDateReceived, conMailListView), "!" + String$(15, "@")), 1, 15)
'將消息的頭信息添加到列表框中
Form1.Mlist.AddItem a$ + Chr$(9) + b$ + Chr$(9) + c$
Form1.Mlist.Refresh
Next i
'消息列表框的索引在第一條沒有閱讀的消息的位置
Form1.Mlist.ListIndex = startindex
Main.Toolbar1.Buttons("Next1").Enabled = True
Main.Toolbar1.Buttons("Previous1").Enabled = True
Main.Toolbar1.Buttons("Delete").Enabled = True
If UnRead Then
'在狀態欄中顯示沒有閱讀的消息的數量
Main.Statusbar1.Panels(1) = "收信箱里共有" + Format$(Main.MAPIMess.MsgCount) + "郵件,其中有" + Format$(UnRead) + "未讀"
Else
Main.Statusbar1.Panels(1) = ""
End If
End Sub
Sub LoadMessage(ByVal Index As Integer, msg As Form)
'將當前消息(根據Index)裝載到窗體msg中
'msg窗體可以是查看消息的窗體Form2,
'也可以是書寫新消息的窗體Form3
If TypeOf msg Is Form2 Then
'如果裝載消息到查看消息的窗體,則根據該消息是否
'被閱讀來清楚消息未讀的標志“*”
a$ = Form1.Mlist.List(Index)
If Mid$(a$, 1, 1) = conUnreadMessage Then
Mid$(a$, 1, 1) = ""
Form1.Mlist.List(Index) = a$
UnRead = UnRead - 1
If UnRead Then
'閱讀的是新消息,則未讀消息的數量-1
Main.Statusbar1.Panels(1) = "收信箱里共有" + Format$(Main.MAPIMess.MsgCount) + "封郵件,其中有" + Format$(UnRead) + "封未讀"
Else
Main.Statusbar1.Panels(1) = "收信箱里共有" + Format$(Main.MAPIMess.MsgCount) + "封郵件,其中有" + Format$(UnRead) + "封未讀"
End If
End If
End If
If TypeOf msg Is Form2 Then
'如果裝載消息到查看消息的窗體,則取得消息的日期和發信人
Main.MAPIMess.MsgIndex = Index
msg.txtDate.Text = "日期:" + DateFromMapiDate$(Main.MAPIMess.MsgDateReceived, conMailLongDate)
msg.txtFrom.Text = "發信人:" + Main.MAPIMess.MsgOrigDisplayName
Form1.Mlist.ItemData(Index) = True
End If
'不管消息裝載到哪個窗體中,均執行以下程序
Call Attachments(msg)
msg.txtNoteText.Text = "郵件" + Chr$(13) + Chr$(10) + Main.MAPIMess.MsgNoteText
msg.txtSubject.Text = "主題:" + Main.MAPIMess.MsgSubject
msg.Caption = Main.MAPIMess.MsgSubject
msg.Tag = Index
msg.txtTo.Text = "收信人:" + GetRCList(Main.MAPIMess, vbRecipTypeTo)
msg.txtCc.Text = "抄送:" + GetRCList(Main.MAPIMess, vbRecipTypeCc)
msg.Refresh
msg.Show
End Sub
Sub LogOffUser()
'該子程序用于注銷發送郵件連接
On Error Resume Next
Main.MAPISess.Action = 2
If Err <> 0 Then
MsgBox "LogOff failure:" + Error
Else
Main.MAPIMess.SessionID = 0
Main.Logoff.Enabled = 0
Main.Logon.Enabled = -1
'卸載所有的子窗體
Do Until Forms.Count = 1
i = Forms.Count - 1
If TypeOf Forms(i) Is MDIForm Then
Else
Unload Forms(i)
End If
Loop
'設置各個菜單項及工具欄按扭的可用狀態
Main.Toolbar1.Buttons("Compose").Enabled = False
Main.Toolbar1.Buttons("Fetch").Enabled = False
Main.Toolbar1.Buttons("Previous1").Enabled = False
Main.Toolbar1.Buttons("Next1").Enabled = False
Main.Toolbar1.Buttons("Delete").Enabled = False
Main.Toolbar1.Buttons("Send").Enabled = False
Main.Toolbar1.Buttons("Reply").Enabled = False
Main.Toolbar1.Buttons("ReplyAll").Enabled = False
Main.Toolbar1.Buttons("Forward").Enabled = False
Main.ShowAB.Enabled = False
Main.Statusbar1.Panels(1) = "現處于離線狀態"
Main.Statusbar1.Panels(2) = ""
End If
End Sub
Sub PrintLongText(ByVal LongText As String)
'打印消息的子程序之一,用于打印消息的正文
Do Until LongText = ""
word$ = Token$(LongText, "")
If Printer.TextHeight(word$) + Printer.CurrentX > Printer.Width - Printer.TextWidth("ZZZZZZZ") Then
Printer.Print
End If
Printer.Print "" + word$
Loop
End Sub
Sub Printmail()
'打印消息的子程序之一,用于取得要打印的消息
If TypeOf Screen.ActiveForm Is Form2 Then
'如果當前活動的子窗體為Form2,則打印相應的郵件消息
Call PrintMessage(Main.MAPIMess, False)
Printer.EndDoc
ElseIf TypeOf Screen.ActiveForm Is Form1 Then
For i = 0 To Form1.Mlist.ListCount - 1
If Form1.Mlist.Selected(i) Then
'如果活動的子窗體是郵件消息列表,則根據列表框中的索引打印
'相應的消息
Main.MAPIMess.MsgIndex = i
Call PrintMessage(Main.MAPIMess, False)
End If
Next i
Printer.EndDoc
End If
End Sub
Sub PrintMessage(msg As Control, fNewPage As Integer)
'打印消息的子程序之一,用于設置打印機和取得打印消息頭
Screen.MousePointer = 11
If fNewPage Then
Printer.NewPage
End If
Printer.FontName = "Arial"
Printer.FontBold = True
Printer.DrawWidth = 10
Printer.Line (0, Printer.CurrentY)-(Printer.Width, Printer.CurrentY)
Printer.Print
Printer.FontSize = 9.75
Printer.Print "From:"
Printer.CurrentX = Printer.TextWidth(String$(30, ""))
Printer.Print msg.MsgOrigDisplayName
Printer.Print "To:"
Printer.CurrentX = Printer.TextWidth(String$(30, ""))
Printe.Print GetRCList(msg, vbRecipTypeTo)
Printer.Print "Cc:"
Printer.CurrentX = Printer.TextWidth(String$(30, ""))
Printer.Print GetRCList(msg, vbRecipTypeCc)
Printer.Print "Subject:"
Printer.CurrentX = Printer.TextWidth(String$(30, ""))
Printer.Print msg.MsgSubject
Printer.Print "Date:"
Printer.CurrentX = Printer.TextWidth(String$(30, ""))
Printer.Print DateFromMapiDate$(msg.MsgDateReceived, conMailLongDate)
Printer.Print
Printer.DrawWidth = 5
Printer.Line (0, Printer.CurrentY)-(Printer.Width, Printer.CurrentY)
Printer.FontSize = 9.75
Printer.FontBold = False
Call PrintLongText(msg.MsgNoteText)
Printer.Print
Screen.MousePointer = 0
End Sub
Sub SetRCList(ByVal NameList As String, msg As Control, RCType As Integer, fResolveNames As Integer)
'根據存儲收信人姓名的字符串NameList(姓名用分號隔開)
'設置收信人姓名。
If NameList = "" Then
Exit Sub
End If
i = msg.RecipCount
Do
msg.RecipIndex = i
msg.RecipDisplayName = Trim$(Token(NameList, ";"))
If fresolvename Then
msg.Action = vbMessageResolveName
End If
msg.RecipType = RCType
i = i + 1
Loop Until (NameList = "")
End Sub
Function Token$(tmp$, search$)
x = InStr(1, tmp$, search$)
If x Then
Token$ = Mid$(tmp$, 1, x - 1)
tmp$ = Mid$(tmp$, x + 1)
Else
Token$ = tmp$
tmp$ = ""
End If
End Function
Sub UpdateRecips(msg As Form)
'更新收信人和轉發的地址
msg.txtTo.Text = GetRCList(Main.MAPIMess, vbRecipTypeTo)
msg.txtCc.Text = GetRCList(Main.MAPIMess, vbRecipTypeCc)
End Sub
Sub ViewNextMsg()
'查看下一個消息
windowNum% = FindMsgWindow(Form1.Mlist.ListIndex)
If windowNum% > 0 Then
Forms(windowNum%).Show
Else
If TypeOf Screen.ActiveForm Is Form2 Then
Call LoadMessage(Form1.Mlist.ListIndex, Screen.ActiveForm)
Else
Call LoadMessage(Form1.Mlist.ListIndex, Form2)
End If
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -