执行下列程序,应该可以弹出对话框,我在Outlook 2002中测试可以,但在Outlook 2003中却不能执行,请各位高手赐教!先谢了!!!
Public WithEvents mail_explorer As Explorer
Dim myEvents As New ThisOutlookSession
Sub initialize_events()
Set myEvents.mail_explorer = Application.Explorers.Item(1)
End Sub
Private Sub mail_explorer_BeforeFolderSwitch _
(ByVal NewFolder As Object, Cancel As Boolean)
If Application.ActiveExplorer.CurrentFolder = "Inbox" Then
Dim mailcount As Integer
Dim mailitem As mailitem
Dim highflag As Integer
Dim msg As String
Dim msg_title As String
Dim proceed As Integer
Dim fld As MAPIFolder
Set fld = Application.GetNamespace("MAPI") _
.GetDefaultFolder(olFolderInbox)
highflag = 0
With fld
For Each mailitem In .Items
If mailitem.Importance = olImportanceHigh And _
mailitem.UnRead = True Then
highflag = highflag + 1
End If
Next
End With
If highflag > 0 Then
msg = "There are unread messages in your Inbox " & _
"flagged with HIGH Importance. Do you still " & _
"wish to leave your Inbox?"
msg_title = highflag & "HIGH IMPORTANCE Messages"
proceed = MsgBox(msg, vbYesNo, msg_title)
If proceed = vbNo Then
Cancel = True
End If
End If
End If
End Sub |