Forcing send & receive by code (VBA)

N

Nour

Hi all,


Is it possible to force a "send & receive" by code?


[This is a summary of a previous post - not resolved yet]

I have an application that sends out faxes ...
The faxes are kept in the outbox waiting for the "send & receive" button
click.
How can I force by code (VBA) the "send & recevive" action to happen just
after I send the fax. I am using MS Fax.

I tried one of the code variation presented in:
http://www.outlookcode.com/d/code/sendnow.htm
here is my code:

Public Sub SendReceiveNow()

Dim oCtl As Office.CommandBarControl
Dim oPop As Office.CommandBarPopup
Dim oCB As Office.CommandBar

Dim ol As New Outlook.Application

'Use the Send/Receive on All Accounts action in the Tools
'menu to send the items from the Outbox, and receive new items
Set oCB = ol.ActiveExplorer.CommandBars("Menu Bar")

Set oPop = oCB.Controls("Tools")
Set oPop = oPop.Controls("Send/Receive")
Set oCtl = oPop.Controls("Send All") '("All Accounts")
oCtl.Execute

Set oCtl = Nothing
Set oPop = Nothing
Set oCB = Nothing
Set ol = Nothing

End Sub

I tried with : "Send All" and "All Accounts" ... but still giving me an
"Automation error " on oCtl.Execute

----------------------------------------------------------------------------
---------------------

I also read in: http://www.kbalertz.com/Feedback.aspx?kbNumber=290500

<< Send CommandBar button
It is no longer possible to use the Execute method to programmatically click
the Send button on the Outlook toolbar. Although this is not commonly done
in Outlook solutions, this change has been made to prevent malicious intent.
You receive the E_FAIL return code for all of these messages in the C or C++
programming languages. >>

Is this true first. If yes, then how to do it otherwise.
 
G

Guest

In Outlook 2003, that menu item is called "Send/Receive All". Not sure about
previous versions.
 

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