Automatic Send/Receive based on email subject

R

Richard

I would like to add a rule using the rule wizard to automatically initiate a
Send/Receive session when my pop3 proxy send a timeout notification back to
Outlook 2002 (SP-2).

I found the following code on the web, but it doesn't work as objCtl is
"Nothing" when it is executed. What's wrong, and how do I make the rules
run this code?

Thanks

Richard
======================
Problematic code:
Public Sub SendReceiveNow()

' Courtesy of http://www.slovaktech.com/code_samples.htm#SendReceive
Dim objOutlook As Outlook.Application
Dim objCtl As Office.CommandBarControl
Dim objPop As Office.CommandBarPopup
Dim objCB As Office.CommandBar
Dim objItem As Object

On Error Resume Next

' Instantiate an Outlook Application object.
Set objOutlook = CreateObject("Outlook.Application")

'First find and send the current item to the Outbox
Set objItem = objOutlook.ActiveInspector.CurrentItem
objItem.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 objCB = objOutlook.ActiveExplorer.CommandBars("Menu Bar")
Set objPop = objCB.Controls("Tools")
Set objPop = objPop.Controls("Send/Receive")
Set objCtl = objPop.Controls("All Accounts")
objCtl.Execute

Set objCtl = Nothing
Set objPop = Nothing
Set objCB = Nothing
Set objItem = Nothing
Set objOutlook = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top