'--- DELIVER method
'--- Requests immediate delivery of all undelivered
' messages submitted in the current session
Public Sub Deliver()
Dim objExplorer As Object 'Temp Explorer object
Dim objFolder As Object 'Temp folder object
Dim objOLCBCol As Object 'Outlook Command Bars Collection object
Dim objOLCB As Object 'Outlook Command Bar object
Dim objOLPop As Object 'Outlook Menu top level item object
Dim objOLCtl As Object 'Outlook Menu command object
'Outlook must be running, ie there is an active Explorer
'else the command bars collection won't be returned
Set objExplorer = objOLApp.ActiveExplorer
If objExplorer Is Nothing Then
'Open an Outlook Explorer
Set objFolder = objOLNS.GetDefaultFolder(olFolderInbox)
Set objExplorer = objFolder.GetExplorer
objExplorer.Activate
End If
'Deliver the message - this will send ~ALL~ items in the Outbox
Set objOLCBCol = objOLApp.ActiveExplorer.CommandBars
'Check we got the command bars - method might fail if
'the operator closed the Explorer
If objOLCBCol Is Nothing Then
Err.Raise oerrNoCommandBars, , _
"Deliver method error - command bars collection not found."
End If
'Get a reference to the Tools menu
Set objOLCB = objOLCBCol("Menu Bar")
'Tools menu is language specific
'101 = Tools
Set objOLPop = objOLCB.Controls(LoadResString(101))
If gintOLVer >= 10 Then
'Using Outlook 2002 or later, Send command no
' longer in Tools menu
'Select Send All in Send/Receive submenu
'105 = Send/Receive
Set objOLPop = objOLPop.Controls(LoadResString(105))
'106 = Send and Receive All
Set objOLCtl = objOLPop.Controls(LoadResString(106))
Else
'Using Outlook 2000 or earlier; select Send in the Tools menu
'102 = Send
Set objOLCtl = objOLPop.Controls(LoadResString(102))
End If
objOLCtl.Execute
'Tidy up
Set objExplorer = Nothing
Set objFolder = Nothing
Set objOLCtl = Nothing
Set objOLPop = Nothing
Set objOLCB = Nothing
Set objOLCBCol = Nothing
End Sub