DeliverNow will error out in IMO mode. You have to use the built-in
toolbar buttons and use the Execute method on them. Here are 2 macros
that do it, one is Send/Receive and the other is Send. If a user has
removed those buttons the code will fail though. The code sends the
currently opened item with focus, but it can be modified to do
something else.
Public Sub SendReceiveNow()
Dim oCtl As Office.CommandBarControl
Dim oPop As Office.CommandBarPopup
Dim oCB As Office.CommandBar
Dim oNS As Outlook.NameSpace
Dim oItem As Object
'First find and send the current item to the Outbox
Set oNS = Application.GetNamespace("MAPI")
Set oItem = Application.ActiveInspector.CurrentItem
oItem.Send
'Then use the Send/Receive on All Accounts action in the Tools
'menu to send the item from the Outbox, and receive new items
Set oCB = Application.ActiveExplorer.CommandBars("Menu Bar")
Set oPop = oCB.Controls("Tools")
Set oPop = oPop.Controls("Send/Receive")
Set oCtl = oPop.Controls("All Accounts")
oCtl.Execute
Set oCtl = Nothing
Set oPop = Nothing
Set oCB = Nothing
Set oNS = Nothing
Set oItem = Nothing
End Sub
Public Sub SendNow()
Dim oCtl As Office.CommandBarControl
Dim oPop As Office.CommandBarPopup
Dim oCB As Office.CommandBar
Dim oNS As Outlook.NameSpace
Dim oItem As Object
'First find and send the current item to the Outbox
Set oNS = Application.GetNamespace("MAPI")
Set oItem = Application.ActiveInspector.CurrentItem
oItem.Send
'Then use the Send action in the Tools menu
'to send the item from the Outbox
Set oCB = Application.ActiveExplorer.CommandBars("Menu Bar")
Set oPop = oCB.Controls("Tools")
Set oCtl = oPop.Controls("Send")
oCtl.Execute
Set oCtl = Nothing
Set oPop = Nothing
Set oCB = Nothing
Set oNS = Nothing
Set oItem = Nothing
End Sub
--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams
Quote:
> How do I send teh Send/Receive Request from
VBA in an IMO
environment (IMAP
> , POP3)?
> (PSI n an Echange Server ita can easily be accomlish using
"DliverNow" from
> CDO)