home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Plus! (NZ) 2001 May
/
PCW0501.iso
/
patch
/
sr2bof97.exe
/
RCDATA
/
CABINET
/
exchange.dsm.95
< prev
next >
Wrap
Text File
|
1998-06-01
|
4KB
|
180 lines
'------------------------------------------------------------------------------
' FILE DESCRIPTION: Macros for development of Exchange Server Applications
'
' Copyright (c) Microsoft Corporation 1993-1997. All rights reserved.
'------------------------------------------------------------------------------
Option Explicit
'------------------------------------------------------------------------------
' Globals
'------------------------------------------------------------------------------
' current file
Dim fShuttingDown
' current file
Dim strFileName
' AM Session
Dim amSession
' Script Locator
Dim aeChooser
' Debugging Aid
Dim fDebug
' fDebug = true
fDebug = false
' DESCRIPTION: Select and open an Exchange Event Service script in the IDE
Sub BrowseExchangeAgents()
On Error Resume Next
If Len(strFileName) = 0 Then
InitGlobals
If Err.Number = 0 Then
strFileName = aeChooser.ChooseScript("Exchange Folder Browser")
If Err.Number = 0 Then
LoadFile
Else
ReportError "ChooseScript"
End If
ElseIf Err.Number <> &H80040113 Then
ReportError "InitGlobals"
End If
Else
MsgBox "You still have an editing session open, please close it before continuing."
End If
End Sub
'------------------------------------------------------------------------------
' Events
'------------------------------------------------------------------------------
' DESCRIPTION: Document is saved and closing. Remove temporary file
Sub Application_BeforeDocumentClose(theDocument)
On Error Resume Next
Dim strTempFileName
Dim nResult
If Len(strFileName) > 0 Then
strTempFileName = LCase(theDocument.FullName)
If strTempFileName = strFileName Then
If fShuttingDown Then
' 4 means vbYesNo
nResult = MsgBox("You are shutting down, do you want to save this agent?", 4)
Else
' 6 means vbYes
nResult = 6
End If
' 6 means vbYes
If nResult = 6 Then
strFileName = aeChooser.PutScript(fShuttingDown)
If Err.Number = 0 Then
If Not fShuttingDown Then
LoadFile
End If
Else
ReportError "PutScript"
End If
End If
If fShuttingDown Then
DeinitGlobals
End If
End If
End If
End Sub
' DESCRIPTION: VS is exiting. Final cleanup
Sub Application_BeforeApplicationShutDown()
On Error Resume Next
fShuttingDown = true
If Len(strFileName) = 0 Then
DeinitGlobals
End If
End Sub
'------------------------------------------------------------------------------
' Helpers
'------------------------------------------------------------------------------
' DESCRIPTION: loads the current file if there is one
Private Sub LoadFile
If Len(strFileName) > 0 Then
Application.Documents.Open(strFileName)
If Err.Number = 0 Then
strFileName = LCase(strFileName)
Else
strFileName = Empty
ReportError "Application.Documents.Open"
End If
End If
End Sub
Private Sub ReportError(strWhatFailed)
Dim strErrMsg
strErrMsg = strWhatFailed & " failed: " & Err.Description & " (" & Hex(Err.Number) & ")"
MsgBox strErrMsg
End Sub
' DESCRIPTION: Initialize session and chooser
Private Sub InitGlobals
On Error Resume Next
Dim amTempSession
Dim aeTempChooser
fShuttingDown = false
If amSession Is Nothing Then
Err.Clear
Set amTempSession = CreateObject("MAPI.Session")
If Err.Number = 0 Then
' Logon with showDialog:=true, newSession:=false, NoMail:=true
amTempSession.Logon "", "", true, true, 0, true
If Err.Number = 0 Then
Application.Active = true
Set aeTempChooser = CreateObject("ActiveEx.ScriptChooser")
If Err.Number = 0 Then
aeTempChooser.Session = amTempSession
If Err.Number = 0 Then
Set amSession = amTempSession
Set aeChooser = aeTempChooser
Else
ReportError "ScriptChooser.Session"
End If
Set aeTempChooser = Nothing
Else
ReportError "CreateObject(ScriptChooser)"
End If
ElseIf Err.Number <> &H80040113 Then
Application.Active = true
ReportError "Session.Logon"
End If
Set amTempSession = Nothing
Else
ReportError "CreateObject(Session)"
End If
End If
End Sub
Private Sub DeinitGlobals
If Not aeChooser Is Nothing Then
Set aeChooser = Nothing
End If
If Not amSession Is Nothing Then
amSession.Logoff
Set amSession = Nothing
End If
Err.Clear
End Sub