
Problem automating "Tools, Send" command
I have a simple sub routine that attempts to execute the
send command (need to send msg in outbox). On my test
machines this works corectly but on a remote PC (which I
can't debug) this bombs out when "objCtl.Execute" is
called.
I need to set the ActiveExplorer menu bar with a default
folder of olFolderInbox because I don't know what view
Outlook may be in, e.g. the tasks could be displayed and
therefore the Menu Bar does not contain the Tools, Send
command. I don't want to use Send & Receive because the
user may not be logged on.
What could be wrong with my code or how can I reliably
execute the send command?
Thanks for any input,
James
Sub SendNow()
Dim olApp As Outlook.Application
Dim objName As NameSpace
Dim objCtl As Office.CommandBarControl
Dim objPop As Office.CommandBarPopup
Dim objCB As Office.CommandBar
Set olApp = Application
Set objName = olApp.GetNamespace("MAPI")
Set myOlExp = olApp.ActiveExplorer
Set myfolder = objName.GetDefaultFolder(olFolderInbox)
Set myexplorer = myfolder.GetExplorer
myexplorer.Display
Set objCB = olApp.ActiveExplorer.CommandBars("Menu
Bar")
Set objPop = objCB.Controls("Tools")
Set objCtl = objPop.Controls("Send")
objCtl.Execute
myexplorer.Close
Set olApp = Nothing
Set objName = Nothing
Set myOlExp = Nothing
Set myfolder = Nothing
Set myexplorer = Nothing
Set ojbcb = Nothing
Set objPop = Nothing
Set objCtl = Nothing
End Sub