467,219 Members | 1,479 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,219 developers. It's quick & easy.

Outlook Express


Is there a way, from Access, to programmatically click the Send and
Receive button in Outlook?

Mar 2 '06 #1
  • viewed: 3847
Share:
26 Replies
On Thu, 02 Mar 2006 17:03:36 -0600, Tom Becker
<wl************@hotmail.com> wrote:

Get the Window Handle of that button, and send (PostMessage) it a
WM_CLICK message.
Why don't you tell us what you really want to do. Send emails perhaps?
How about DoCmd.SendObject?

-Tom.


Is there a way, from Access, to programmatically click the Send and
Receive button in Outlook?


Mar 3 '06 #2
Tom Becker wrote:
Is there a way, from Access, to programmatically click the Send and
Receive button in Outlook?


T.B., here is an A2K mdb code snippet from about five years ago for
plain Outlook 2K:

'Send/Receive
Set MyExplorer = objOutlook.ActiveExplorer
MyExplorer.Activate
MyExplorer.WindowState = olMaximized
Set MyMenuBar = MyExplorer.CommandBars.Item("Standard")
Set MyMenuBarControl = MyMenuBar.Controls.Item("Send/Re&ceive")
MyMenuBarControl.Execute
Set MyMenuBar = Nothing

Some Dim's:
Dim MyExplorer As Explorer
Dim MyMenuBar As CommandBar
Dim MyMenuBarControl As CommandBarControl
Dim objOutlook As Outlook.Application

This needs a reference set to the Outlook Object library. I dug up
this example before I noticed the word "Express" in your subject line
but it may give you some ideas. Note that Outlook is easier to
automate than Outlook Express.

James A. Fortune
CD********@FortuneJames.com

Mar 3 '06 #3
On Thu, 02 Mar 2006 22:06:11 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Thu, 02 Mar 2006 17:03:36 -0600, Tom Becker
<wl************@hotmail.com> wrote:

Get the Window Handle of that button, and send (PostMessage) it a
WM_CLICK message.
Why don't you tell us what you really want to do. Send emails perhaps?
How about DoCmd.SendObject?

-Tom.
Can you tell me more about Window Handles of buttons and WM_CLICK?

I use DoCmd.SendObject but sometimes it's sits in the Outbox in
Outlook. I want to make sure it sends the email right away by clicking
Send and Receive.



Is there a way, from Access, to programmatically click the Send and
Receive button in Outlook?


Mar 3 '06 #4
On Fri, 03 Mar 2006 05:45:08 -0600, Tom Becker
<wl************@hotmail.com> wrote:

Window handles etc are related to low-level Windows API programming.
Not recommended but as the very last resort.

"Sometimes it sits in the Outbox" sounds more like a configuration or
connectivity problem than a programming problem.

-Tom.

On Thu, 02 Mar 2006 22:06:11 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Thu, 02 Mar 2006 17:03:36 -0600, Tom Becker
<wl************@hotmail.com> wrote:

Get the Window Handle of that button, and send (PostMessage) it a
WM_CLICK message.
Why don't you tell us what you really want to do. Send emails perhaps?
How about DoCmd.SendObject?

-Tom.


Can you tell me more about Window Handles of buttons and WM_CLICK?

I use DoCmd.SendObject but sometimes it's sits in the Outbox in
Outlook. I want to make sure it sends the email right away by clicking
Send and Receive.



Is there a way, from Access, to programmatically click the Send and
Receive button in Outlook?


Mar 3 '06 #5
On 2 Mar 2006 23:40:16 -0800, CD********@FortuneJames.com wrote:
Tom Becker wrote:
Is there a way, from Access, to programmatically click the Send and
Receive button in Outlook?


T.B., here is an A2K mdb code snippet from about five years ago for
plain Outlook 2K:

'Send/Receive
Set MyExplorer = objOutlook.ActiveExplorer
MyExplorer.Activate
MyExplorer.WindowState = olMaximized
Set MyMenuBar = MyExplorer.CommandBars.Item("Standard")
Set MyMenuBarControl = MyMenuBar.Controls.Item("Send/Re&ceive")
MyMenuBarControl.Execute
Set MyMenuBar = Nothing

Some Dim's:
Dim MyExplorer As Explorer
Dim MyMenuBar As CommandBar
Dim MyMenuBarControl As CommandBarControl
Dim objOutlook As Outlook.Application

This needs a reference set to the Outlook Object library. I dug up
this example before I noticed the word "Express" in your subject line
but it may give you some ideas. Note that Outlook is easier to
automate than Outlook Express.

James A. Fortune
CD********@FortuneJames.com


Thanks! It looks like I need to change something to make it work in
Access 2002 though. It is with Outlook and not Outlook Express.

I get an error on this line:
Set MyExplorer = objOutlook.ActiveExplorer

The error says, "object variable or with block not set"

Dimming As CommandBar didn't work when when I added a reference to
Microsoft Outlook 10.0 object library, but it did work when I also
added Microsoft Office 10.0 object library.

Any ideas on what needs to be done?
Mar 3 '06 #6
On Fri, 03 Mar 2006 06:37:27 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Fri, 03 Mar 2006 05:45:08 -0600, Tom Becker
<wl************@hotmail.com> wrote:

Window handles etc are related to low-level Windows API programming.
Not recommended but as the very last resort.

"Sometimes it sits in the Outbox" sounds more like a configuration or
connectivity problem than a programming problem.

-Tom.

On the configuration possibility I could check on the settings in
Outlook, But is there anything I can do about a connectivity problem?
This is over a LAN.
Mar 3 '06 #7
Tom Becker wrote:
On 2 Mar 2006 23:40:16 -0800, CD********@FortuneJames.com wrote:
Tom Becker wrote:
Is there a way, from Access, to programmatically click the Send and
Receive button in Outlook?


T.B., here is an A2K mdb code snippet from about five years ago for
plain Outlook 2K:

'Send/Receive
Set MyExplorer = objOutlook.ActiveExplorer
MyExplorer.Activate
MyExplorer.WindowState = olMaximized
Set MyMenuBar = MyExplorer.CommandBars.Item("Standard")
Set MyMenuBarControl = MyMenuBar.Controls.Item("Send/Re&ceive")
MyMenuBarControl.Execute
Set MyMenuBar = Nothing

Some Dim's:
Dim MyExplorer As Explorer
Dim MyMenuBar As CommandBar
Dim MyMenuBarControl As CommandBarControl
Dim objOutlook As Outlook.Application

This needs a reference set to the Outlook Object library. I dug up
this example before I noticed the word "Express" in your subject line
but it may give you some ideas. Note that Outlook is easier to
automate than Outlook Express.

James A. Fortune
CD********@FortuneJames.com


Thanks! It looks like I need to change something to make it work in
Access 2002 though. It is with Outlook and not Outlook Express.

I get an error on this line:
Set MyExplorer = objOutlook.ActiveExplorer

The error says, "object variable or with block not set"

Dimming As CommandBar didn't work when when I added a reference to
Microsoft Outlook 10.0 object library, but it did work when I also
added Microsoft Office 10.0 object library.

Any ideas on what needs to be done?


I like your initiative. It needs a little more. Run a function to see
if outlook is running. If it's not running, I did:

Shell ("C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\OUTLOOK.EXE")
For I = 1 To 1700
DoEvents
Next I

before

Set objOutlook = GetObject("", "Outlook.Application")

Another way is to use CreateObject for the case when outlook is not
running. Something like:

Set objOutlook = CreateObject("", "Outlook.Application")

before running the Send/Receive code.

Also, be careful to set objects back to Nothing when you're done using
them so that Access can close Outlook. That should get you close.

James A. Fortune
CD********@FortuneJames.com

Verisign wants a perpetual unsupervised monopoly on the .COM registry:

http://www.bobparsons.com/EconomicsLesson.html

Mar 3 '06 #8
On 3 Mar 2006 15:17:34 -0800, CD********@FortuneJames.com wrote:
I like your initiative. It needs a little more. Run a function to see
if outlook is running. If it's not running, I did:


**Based on code from Stephen Lebans

Function fIsOulookThere() As Integer
' Open the installed Version of MS Outlook
Dim OL As Object

On Error Resume Next
'See if Outlook is running
Err.Clear
' Is Outlook running?
Set OL = GetObject(, "Outlook.Application")
' Error if not running
If Err.Number <> 0 Then
' Clear Error object
Err.Clear
'Create a new instance of Outlook
Set OL = CreateObject("Outlook.Application")
If Err.Number <> 0 Then
'not installed
fIsOulookThere = 0
Else
'installed but not running
fIsOulookThere = 2
End If
Else
'yes it is running
fIsOulookThere = 1
End If

If Not IsEmpty(OL) Then Set OL = Nothing

End Function

Wayne Gillespie
Gosford NSW Australia
Mar 4 '06 #9
On 3 Mar 2006 15:17:34 -0800, CD********@FortuneJames.com wrote:
Tom Becker wrote:
On 2 Mar 2006 23:40:16 -0800, CD********@FortuneJames.com wrote:
>Tom Becker wrote:
>> Is there a way, from Access, to programmatically click the Send and
>> Receive button in Outlook?
>
>T.B., here is an A2K mdb code snippet from about five years ago for
>plain Outlook 2K:
>
>'Send/Receive
>Set MyExplorer = objOutlook.ActiveExplorer
>MyExplorer.Activate
>MyExplorer.WindowState = olMaximized
>Set MyMenuBar = MyExplorer.CommandBars.Item("Standard")
>Set MyMenuBarControl = MyMenuBar.Controls.Item("Send/Re&ceive")
>MyMenuBarControl.Execute
>Set MyMenuBar = Nothing
>
>Some Dim's:
>Dim MyExplorer As Explorer
>Dim MyMenuBar As CommandBar
>Dim MyMenuBarControl As CommandBarControl
>Dim objOutlook As Outlook.Application
>
>This needs a reference set to the Outlook Object library. I dug up
>this example before I noticed the word "Express" in your subject line
>but it may give you some ideas. Note that Outlook is easier to
>automate than Outlook Express.
>
>James A. Fortune
>CD********@FortuneJames.com
Thanks! It looks like I need to change something to make it work in
Access 2002 though. It is with Outlook and not Outlook Express.

I get an error on this line:
Set MyExplorer = objOutlook.ActiveExplorer

The error says, "object variable or with block not set"

Dimming As CommandBar didn't work when when I added a reference to
Microsoft Outlook 10.0 object library, but it did work when I also
added Microsoft Office 10.0 object library.

Any ideas on what needs to be done?


I like your initiative. It needs a little more. Run a function to see
if outlook is running. If it's not running, I did:

Shell ("C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\OUTLOOK.EXE")
For I = 1 To 1700
DoEvents
Next I

before

Set objOutlook = GetObject("", "Outlook.Application")

Another way is to use CreateObject for the case when outlook is not
running. Something like:

Set objOutlook = CreateObject("", "Outlook.Application")

before running the Send/Receive code.

Also, be careful to set objects back to Nothing when you're done using
them so that Access can close Outlook. That should get you close.


Thanks! I want to try it when I go back on monday. But do you have a
function that sees if Outlook is running?


James A. Fortune
CD********@FortuneJames.com

Verisign wants a perpetual unsupervised monopoly on the .COM registry:

http://www.bobparsons.com/EconomicsLesson.html


Mar 4 '06 #10
On Fri, 03 Mar 2006 23:54:09 GMT, Wayne Gillespie
<be*****@NOhotmailSPAM.com.au> wrote:
On 3 Mar 2006 15:17:34 -0800, CD********@FortuneJames.com wrote:
I like your initiative. It needs a little more. Run a function to see
if outlook is running. If it's not running, I did:


**Based on code from Stephen Lebans

Function fIsOulookThere() As Integer
' Open the installed Version of MS Outlook
Dim OL As Object

On Error Resume Next
'See if Outlook is running
Err.Clear
' Is Outlook running?
Set OL = GetObject(, "Outlook.Application")
' Error if not running
If Err.Number <> 0 Then
' Clear Error object
Err.Clear
'Create a new instance of Outlook
Set OL = CreateObject("Outlook.Application")
If Err.Number <> 0 Then
'not installed
fIsOulookThere = 0
Else
'installed but not running
fIsOulookThere = 2
End If
Else
'yes it is running
fIsOulookThere = 1
End If

If Not IsEmpty(OL) Then Set OL = Nothing

End Function

Wayne Gillespie
Gosford NSW Australia


That works! Thanks!
Mar 4 '06 #11
On 3 Mar 2006 15:17:34 -0800, CD********@FortuneJames.com wrote:
Tom Becker wrote:
On 2 Mar 2006 23:40:16 -0800, CD********@FortuneJames.com wrote:
>Tom Becker wrote:
>> Is there a way, from Access, to programmatically click the Send and
>> Receive button in Outlook?
>
>T.B., here is an A2K mdb code snippet from about five years ago for
>plain Outlook 2K:
>
>'Send/Receive
>Set MyExplorer = objOutlook.ActiveExplorer
>MyExplorer.Activate
>MyExplorer.WindowState = olMaximized
>Set MyMenuBar = MyExplorer.CommandBars.Item("Standard")
>Set MyMenuBarControl = MyMenuBar.Controls.Item("Send/Re&ceive")
>MyMenuBarControl.Execute
>Set MyMenuBar = Nothing
>
>Some Dim's:
>Dim MyExplorer As Explorer
>Dim MyMenuBar As CommandBar
>Dim MyMenuBarControl As CommandBarControl
>Dim objOutlook As Outlook.Application
>
>This needs a reference set to the Outlook Object library. I dug up
>this example before I noticed the word "Express" in your subject line
>but it may give you some ideas. Note that Outlook is easier to
>automate than Outlook Express.
>
>James A. Fortune
>CD********@FortuneJames.com


Thanks! It looks like I need to change something to make it work in
Access 2002 though. It is with Outlook and not Outlook Express.

I get an error on this line:
Set MyExplorer = objOutlook.ActiveExplorer

The error says, "object variable or with block not set"

Dimming As CommandBar didn't work when when I added a reference to
Microsoft Outlook 10.0 object library, but it did work when I also
added Microsoft Office 10.0 object library.

Any ideas on what needs to be done?


I like your initiative. It needs a little more. Run a function to see
if outlook is running. If it's not running, I did:

Shell ("C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\OUTLOOK.EXE")
For I = 1 To 1700
DoEvents
Next I

before

Set objOutlook = GetObject("", "Outlook.Application")

Another way is to use CreateObject for the case when outlook is not
running. Something like:

Set objOutlook = CreateObject("", "Outlook.Application")

before running the Send/Receive code.

Also, be careful to set objects back to Nothing when you're done using
them so that Access can close Outlook. That should get you close.

James A. Fortune
CD********@FortuneJames.com

Verisign wants a perpetual unsupervised monopoly on the .COM registry:

http://www.bobparsons.com/EconomicsLesson.html


Thanks again for looking into this. But with Outlook running and
trying it in Access 2000 I get the error on

Set MyExplorer = objOutlook.ActiveExplorer
Mar 4 '06 #12

Tom Becker wrote:
On 3 Mar 2006 15:17:34 -0800, CD********@FortuneJames.com wrote:
Tom Becker wrote:
On 2 Mar 2006 23:40:16 -0800, CD********@FortuneJames.com wrote:

>Tom Becker wrote:
>> Is there a way, from Access, to programmatically click the Send and
>> Receive button in Outlook?
>
>T.B., here is an A2K mdb code snippet from about five years ago for
>plain Outlook 2K:
>
>'Send/Receive
>Set MyExplorer = objOutlook.ActiveExplorer
>MyExplorer.Activate
>MyExplorer.WindowState = olMaximized
>Set MyMenuBar = MyExplorer.CommandBars.Item("Standard")
>Set MyMenuBarControl = MyMenuBar.Controls.Item("Send/Re&ceive")
>MyMenuBarControl.Execute
>Set MyMenuBar = Nothing
>
>Some Dim's:
>Dim MyExplorer As Explorer
>Dim MyMenuBar As CommandBar
>Dim MyMenuBarControl As CommandBarControl
>Dim objOutlook As Outlook.Application
>
>This needs a reference set to the Outlook Object library. I dug up
>this example before I noticed the word "Express" in your subject line
>but it may give you some ideas. Note that Outlook is easier to
>automate than Outlook Express.
>
>James A. Fortune
>CD********@FortuneJames.com

Thanks! It looks like I need to change something to make it work in
Access 2002 though. It is with Outlook and not Outlook Express.

I get an error on this line:
Set MyExplorer = objOutlook.ActiveExplorer

The error says, "object variable or with block not set"

Dimming As CommandBar didn't work when when I added a reference to
Microsoft Outlook 10.0 object library, but it did work when I also
added Microsoft Office 10.0 object library.

Any ideas on what needs to be done?


I like your initiative. It needs a little more. Run a function to see
if outlook is running. If it's not running, I did:

Shell ("C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\OUTLOOK.EXE")
For I = 1 To 1700
DoEvents
Next I

before

Set objOutlook = GetObject("", "Outlook.Application")

Another way is to use CreateObject for the case when outlook is not
running. Something like:

Set objOutlook = CreateObject("", "Outlook.Application")

before running the Send/Receive code.

Also, be careful to set objects back to Nothing when you're done using
them so that Access can close Outlook. That should get you close.

James A. Fortune
CD********@FortuneJames.com

Verisign wants a perpetual unsupervised monopoly on the .COM registry:

http://www.bobparsons.com/EconomicsLesson.html


Thanks again for looking into this. But with Outlook running and
trying it in Access 2000 I get the error on

Set MyExplorer = objOutlook.ActiveExplorer


I know the code I posted worked with Outlook 2K. Let's see if the
automation part is working. Make sure the reference to 'OLE
Automation' is set :-). Will objOutlook let you do something simple
like minimize Outlook?

James A. Fortune
CD********@FortuneJames.com

Mar 5 '06 #13
On 4 Mar 2006 16:14:16 -0800, CD********@FortuneJames.com wrote:

Tom Becker wrote:
On 3 Mar 2006 15:17:34 -0800, CD********@FortuneJames.com wrote:
>Tom Becker wrote:
>> On 2 Mar 2006 23:40:16 -0800, CD********@FortuneJames.com wrote:
>>
>> >Tom Becker wrote:
>> >> Is there a way, from Access, to programmatically click the Send and
>> >> Receive button in Outlook?
>> >
>> >T.B., here is an A2K mdb code snippet from about five years ago for
>> >plain Outlook 2K:
>> >
>> >'Send/Receive
>> >Set MyExplorer = objOutlook.ActiveExplorer
>> >MyExplorer.Activate
>> >MyExplorer.WindowState = olMaximized
>> >Set MyMenuBar = MyExplorer.CommandBars.Item("Standard")
>> >Set MyMenuBarControl = MyMenuBar.Controls.Item("Send/Re&ceive")
>> >MyMenuBarControl.Execute
>> >Set MyMenuBar = Nothing
>> >
>> >Some Dim's:
>> >Dim MyExplorer As Explorer
>> >Dim MyMenuBar As CommandBar
>> >Dim MyMenuBarControl As CommandBarControl
>> >Dim objOutlook As Outlook.Application
>> >
>> >This needs a reference set to the Outlook Object library. I dug up
>> >this example before I noticed the word "Express" in your subject line
>> >but it may give you some ideas. Note that Outlook is easier to
>> >automate than Outlook Express.
>> >
>> >James A. Fortune
>> >CD********@FortuneJames.com
>>
>> Thanks! It looks like I need to change something to make it work in
>> Access 2002 though. It is with Outlook and not Outlook Express.
>>
>> I get an error on this line:
>> Set MyExplorer = objOutlook.ActiveExplorer
>>
>> The error says, "object variable or with block not set"
>>
>> Dimming As CommandBar didn't work when when I added a reference to
>> Microsoft Outlook 10.0 object library, but it did work when I also
>> added Microsoft Office 10.0 object library.
>>
>> Any ideas on what needs to be done?
>
>I like your initiative. It needs a little more. Run a function to see
>if outlook is running. If it's not running, I did:
>
> Shell ("C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\OUTLOOK.EXE")
> For I = 1 To 1700
> DoEvents
> Next I
>
>before
>
>Set objOutlook = GetObject("", "Outlook.Application")
>
>Another way is to use CreateObject for the case when outlook is not
>running. Something like:
>
>Set objOutlook = CreateObject("", "Outlook.Application")
>
>before running the Send/Receive code.
>
>Also, be careful to set objects back to Nothing when you're done using
>them so that Access can close Outlook. That should get you close.
>
>James A. Fortune
>CD********@FortuneJames.com
>
>Verisign wants a perpetual unsupervised monopoly on the .COM registry:
>
>http://www.bobparsons.com/EconomicsLesson.html


Thanks again for looking into this. But with Outlook running and
trying it in Access 2000 I get the error on

Set MyExplorer = objOutlook.ActiveExplorer


I know the code I posted worked with Outlook 2K. Let's see if the
automation part is working. Make sure the reference to 'OLE
Automation' is set :-). Will objOutlook let you do something simple
like minimize Outlook?


OLE Automation is checked. It won't do anything. I get an error
message on the first line of the code saying:

Object Variable or With Block not set.

I am trying it with Outlook2K.
Mar 5 '06 #14
I'll post the entire list of referenced I used, tonight or tomorrow.
After that, if you still have difficulties I'll try to help you find
the problem. It has to be something pretty simple.

James A. Fortune
CD********@FortuneJames.com

Mar 6 '06 #15
On 6 Mar 2006 12:56:02 -0800, CD********@FortuneJames.com wrote:
I'll post the entire list of referenced I used, tonight or tomorrow.
After that, if you still have difficulties I'll try to help you find
the problem. It has to be something pretty simple.

Great! Thanks! If it worked before there must be a way.
Mar 6 '06 #16
Tom Becker wrote:
On 6 Mar 2006 12:56:02 -0800, CD********@FortuneJames.com wrote:
I'll post the entire list of referenced I used, tonight or tomorrow.
references (my brain was moving faster than my fingers)
After that, if you still have difficulties I'll try to help you find
the problem. It has to be something pretty simple.

Great! Thanks! If it worked before there must be a way.


Here it is (in the order I used):

Visual Basic For Applications
Microsoft Access 9.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft Outlook 9.0 Object Library
Microsoft Office 9.0 Object Library
Microsoft Word 9.0 Object Library
Microsoft Calendar Control 9.0
Microsoft Windows Common Controls 6.0 (SP3)
Microsoft Office Web Components 9.0
Microsoft Forms 2.0 Object Library
LinkDC.adp

James A. Fortune
CD********@FortuneJames.com

Mar 7 '06 #17
On 6 Mar 2006 16:56:15 -0800, CD********@FortuneJames.com wrote:
Tom Becker wrote:
On 6 Mar 2006 12:56:02 -0800, CD********@FortuneJames.com wrote:
>I'll post the entire list of referenced I used, tonight or tomorrow.
references (my brain was moving faster than my fingers)
>After that, if you still have difficulties I'll try to help you find
>the problem. It has to be something pretty simple.
>

Great! Thanks! If it worked before there must be a way.


Here it is (in the order I used):

Visual Basic For Applications
Microsoft Access 9.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft Outlook 9.0 Object Library
Microsoft Office 9.0 Object Library
Microsoft Word 9.0 Object Library
Microsoft Calendar Control 9.0
Microsoft Windows Common Controls 6.0 (SP3)
Microsoft Office Web Components 9.0
Microsoft Forms 2.0 Object Library
LinkDC.adp

James A. Fortune
CD********@FortuneJames.com


Some of them are not on my list of references to select from.

I don't have the calandar control, I doubt if that is the problem.

I don't have Microsoft Windows Common Controls 6.0 (SP3)
(though I do have Service Pack 3 installed)

I don't have Microsoft Office Web Components 9.0

I don't have Microsoft Forms 2.0 Object Library

And I don't have LinkDC.adp

I'm still getting the same error. How did you get those references on
your list?
Mar 7 '06 #18
Tom Becker wrote:
On 6 Mar 2006 16:56:15 -0800, CD********@FortuneJames.com wrote:
Tom Becker wrote:
On 6 Mar 2006 12:56:02 -0800, CD********@FortuneJames.com wrote:

>I'll post the entire list of referenced I used, tonight or tomorrow.


references (my brain was moving faster than my fingers)
>After that, if you still have difficulties I'll try to help you find
>the problem. It has to be something pretty simple.
>
Great! Thanks! If it worked before there must be a way.


Here it is (in the order I used):

Visual Basic For Applications
Microsoft Access 9.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft Outlook 9.0 Object Library
Microsoft Office 9.0 Object Library
Microsoft Word 9.0 Object Library
Microsoft Calendar Control 9.0
Microsoft Windows Common Controls 6.0 (SP3)
Microsoft Office Web Components 9.0
Microsoft Forms 2.0 Object Library
LinkDC.adp

James A. Fortune
CD********@FortuneJames.com


Some of them are not on my list of references to select from.

I don't have the calandar control, I doubt if that is the problem.

I don't have Microsoft Windows Common Controls 6.0 (SP3)
(though I do have Service Pack 3 installed)

I don't have Microsoft Office Web Components 9.0

I don't have Microsoft Forms 2.0 Object Library

And I don't have LinkDC.adp

I'm still getting the same error. How did you get those references on
your list?


Automation shouldn't need many references, certainly not anything
special. As to how I got those references it looks like I'll have to
do some investigating. I know I had Enterprise Manager on the original
machine from some kind of MS developer's tools disk. I'll look to see
exactly what disk that was. I think many of the references were put
there automatically when I used various controls. Please post your
code excerpt and appropriate Dim statements. I wanted to make sure it
wasn't a references issue before looking at code. LinkDC.adp was
simply used to link to some hosted SQL Server data.

James A. Fortune
CD********@FortuneJames.com

Mar 7 '06 #19
On 7 Mar 2006 08:08:09 -0800, CD********@FortuneJames.com wrote:
Tom Becker wrote:
On 6 Mar 2006 16:56:15 -0800, CD********@FortuneJames.com wrote:
>Tom Becker wrote:
>> On 6 Mar 2006 12:56:02 -0800, CD********@FortuneJames.com wrote:
>>
>> >I'll post the entire list of referenced I used, tonight or tomorrow.
>
>references (my brain was moving faster than my fingers)
>
>> >After that, if you still have difficulties I'll try to help you find
>> >the problem. It has to be something pretty simple.
>> >
>> Great! Thanks! If it worked before there must be a way.
>
>Here it is (in the order I used):
>
>Visual Basic For Applications
>Microsoft Access 9.0 Object Library
>Microsoft DAO 3.6 Object Library
>OLE Automation
>Microsoft ActiveX Data Objects 2.1 Library
>Microsoft Outlook 9.0 Object Library
>Microsoft Office 9.0 Object Library
>Microsoft Word 9.0 Object Library
>Microsoft Calendar Control 9.0
>Microsoft Windows Common Controls 6.0 (SP3)
>Microsoft Office Web Components 9.0
>Microsoft Forms 2.0 Object Library
>LinkDC.adp
>
>James A. Fortune
>CD********@FortuneJames.com


Some of them are not on my list of references to select from.

I don't have the calandar control, I doubt if that is the problem.

I don't have Microsoft Windows Common Controls 6.0 (SP3)
(though I do have Service Pack 3 installed)

I don't have Microsoft Office Web Components 9.0

I don't have Microsoft Forms 2.0 Object Library

And I don't have LinkDC.adp

I'm still getting the same error. How did you get those references on
your list?


Automation shouldn't need many references, certainly not anything
special. As to how I got those references it looks like I'll have to
do some investigating. I know I had Enterprise Manager on the original
machine from some kind of MS developer's tools disk. I'll look to see
exactly what disk that was. I think many of the references were put
there automatically when I used various controls. Please post your
code excerpt and appropriate Dim statements. I wanted to make sure it
wasn't a references issue before looking at code. LinkDC.adp was
simply used to link to some hosted SQL Server data.

James A. Fortune
CD********@FortuneJames.com


I copied what you sent before:

Private Sub cmdSendRec_Click()
Dim MyExplorer As Explorer
Dim MyMenuBar As CommandBar
Dim MyMenuBarControl As CommandBarControl
Dim objOutlook As Outlook.Application

Set MyExplorer = objOutlook.ActiveExplorer
MyExplorer.Activate
MyExplorer.WindowState = olMaximized
Set MyMenuBar = MyExplorer.CommandBars.Item("Standard")
Set MyMenuBarControl = MyMenuBar.Controls.Item("Send/Re&ceive")
MyMenuBarControl.Execute
Set MyMenuBar = Nothing

'This needs a reference set to the Outlook Object library.
End Sub

I try this with Outlook already open. The "Receive" part doesn't
look right but I get the error on the first line.

Mar 7 '06 #20
Tom Becker wrote:
On 7 Mar 2006 08:08:09 -0800, CD********@FortuneJames.com wrote:
Tom Becker wrote:
On 6 Mar 2006 16:56:15 -0800, CD********@FortuneJames.com wrote:

>Tom Becker wrote:
>> On 6 Mar 2006 12:56:02 -0800, CD********@FortuneJames.com wrote:
>>
>> >I'll post the entire list of referenced I used, tonight or tomorrow.
>
>references (my brain was moving faster than my fingers)
>
>> >After that, if you still have difficulties I'll try to help you find
>> >the problem. It has to be something pretty simple.
>> >
>> Great! Thanks! If it worked before there must be a way.
>
>Here it is (in the order I used):
>
>Visual Basic For Applications
>Microsoft Access 9.0 Object Library
>Microsoft DAO 3.6 Object Library
>OLE Automation
>Microsoft ActiveX Data Objects 2.1 Library
>Microsoft Outlook 9.0 Object Library
>Microsoft Office 9.0 Object Library
>Microsoft Word 9.0 Object Library
>Microsoft Calendar Control 9.0
>Microsoft Windows Common Controls 6.0 (SP3)
>Microsoft Office Web Components 9.0
>Microsoft Forms 2.0 Object Library
>LinkDC.adp
>
>James A. Fortune
>CD********@FortuneJames.com

Some of them are not on my list of references to select from.

I don't have the calandar control, I doubt if that is the problem.

I don't have Microsoft Windows Common Controls 6.0 (SP3)
(though I do have Service Pack 3 installed)

I don't have Microsoft Office Web Components 9.0

I don't have Microsoft Forms 2.0 Object Library

And I don't have LinkDC.adp

I'm still getting the same error. How did you get those references on
your list?


Automation shouldn't need many references, certainly not anything
special. As to how I got those references it looks like I'll have to
do some investigating. I know I had Enterprise Manager on the original
machine from some kind of MS developer's tools disk. I'll look to see
exactly what disk that was. I think many of the references were put
there automatically when I used various controls. Please post your
code excerpt and appropriate Dim statements. I wanted to make sure it
wasn't a references issue before looking at code. LinkDC.adp was
simply used to link to some hosted SQL Server data.

James A. Fortune
CD********@FortuneJames.com


I copied what you sent before:

Private Sub cmdSendRec_Click()
Dim MyExplorer As Explorer
Dim MyMenuBar As CommandBar
Dim MyMenuBarControl As CommandBarControl
Dim objOutlook As Outlook.Application

Set MyExplorer = objOutlook.ActiveExplorer
MyExplorer.Activate
MyExplorer.WindowState = olMaximized
Set MyMenuBar = MyExplorer.CommandBars.Item("Standard")
Set MyMenuBarControl = MyMenuBar.Controls.Item("Send/Re&ceive")
MyMenuBarControl.Execute
Set MyMenuBar = Nothing

'This needs a reference set to the Outlook Object library.
End Sub

I try this with Outlook already open. The "Receive" part doesn't
look right but I get the error on the first line.


objOutlook isn't set. If Outlook is already open, put:

Set objOutlook = GetObject("", "Outlook.Application")

before the line that says:

Set MyExplorer = objOutlook.ActiveExplorer

The Send/Re&ceive is correct. The & had to be there to indicate that
the "c" is underlined for the Alt shortcut.

BTW, the Enterprise Manager came from the Microsoft Office 2000
Developer CD. This software is illegal without a separate license from
Microsoft. Since he wriggled out of paying for that database at the
98% completion point, I doubt he bothered to obtain a license either.

James A. Fortune
CD********@FortuneJames.com

Mar 8 '06 #21
On 8 Mar 2006 10:05:48 -0800, CD********@FortuneJames.com wrote:


objOutlook isn't set. If Outlook is already open, put:

Set objOutlook = GetObject("", "Outlook.Application")

before the line that says:

Set MyExplorer = objOutlook.ActiveExplorer

The Send/Re&ceive is correct. The & had to be there to indicate that
the "c" is underlined for the Alt shortcut.

BTW, the Enterprise Manager came from the Microsoft Office 2000
Developer CD. This software is illegal without a separate license from
Microsoft. Since he wriggled out of paying for that database at the
98% completion point, I doubt he bothered to obtain a license either.

James A. Fortune
CD********@FortuneJames.com


Very Cool! Thanks!

Do you happen to have code handy that closes Outlook? I should do
that at the end.
Mar 8 '06 #22
On Wed, 08 Mar 2006 16:28:59 -0600, Tom Becker
<wl************@hotmail.com> wrote:
On 8 Mar 2006 10:05:48 -0800, CD********@FortuneJames.com wrote:


objOutlook isn't set. If Outlook is already open, put:

Set objOutlook = GetObject("", "Outlook.Application")

before the line that says:

Set MyExplorer = objOutlook.ActiveExplorer

The Send/Re&ceive is correct. The & had to be there to indicate that
the "c" is underlined for the Alt shortcut.

BTW, the Enterprise Manager came from the Microsoft Office 2000
Developer CD. This software is illegal without a separate license from
Microsoft. Since he wriggled out of paying for that database at the
98% completion point, I doubt he bothered to obtain a license either.

James A. Fortune
CD********@FortuneJames.com


Very Cool! Thanks!

Do you happen to have code handy that closes Outlook? I should do
that at the end.


I noticed after writing this that objOutlook.Quit would close it. But
maybe I shouldn't since it could close before it's done sending and
recieving. Closing isn't really necessary. Thanks again!
Mar 9 '06 #23
Tom Becker wrote:
On Wed, 08 Mar 2006 16:28:59 -0600, Tom Becker
<wl************@hotmail.com> wrote:
On 8 Mar 2006 10:05:48 -0800, CD********@FortuneJames.com wrote:


objOutlook isn't set. If Outlook is already open, put:

Set objOutlook = GetObject("", "Outlook.Application")

before the line that says:

Set MyExplorer = objOutlook.ActiveExplorer

The Send/Re&ceive is correct. The & had to be there to indicate that
the "c" is underlined for the Alt shortcut.

BTW, the Enterprise Manager came from the Microsoft Office 2000
Developer CD. This software is illegal without a separate license from
Microsoft. Since he wriggled out of paying for that database at the
98% completion point, I doubt he bothered to obtain a license either.

James A. Fortune
CD********@FortuneJames.com


Very Cool! Thanks!

Do you happen to have code handy that closes Outlook? I should do
that at the end.


I noticed after writing this that objOutlook.Quit would close it. But
maybe I shouldn't since it could close before it's done sending and
recieving. Closing isn't really necessary. Thanks again!


I've got the code. I'll have to pare it down to the essentials for
you. I think I monitored the activity of certain critical folders and
waited until there was no activity for a certain amount of time before
closing Outlook.

James A. Fortune
CD********@FortuneJames.com

Mar 9 '06 #24
On 9 Mar 2006 11:39:45 -0800, CD********@FortuneJames.com wrote:


I've got the code. I'll have to pare it down to the essentials for
you. I think I monitored the activity of certain critical folders and
waited until there was no activity for a certain amount of time before
closing Outlook.

Thanks much. I would like to have that.

I ran into a bigger problem though. I actually need to use it on
Access 2002.

Here's what happened:

If Outlook is not open it opens it fine.

If Outlook is already open it runs Send and Receive.

But, if the program opens Outlook, for some reason it makes an error
when I try the Send and Receive code.

So something must be different about the outlook that opens with your
Shell code and the outlook that opens from the icons on the desktop.

From the desktop the shortcut points to Outlook.exe with this at the
end- /recycle It has the slash going the other way and it's not
part of the path. .....OUTLOOK.EXE" /recycle I don't know if that
has anything to do with the problem though.

Do you have any idea what could be different about the Outlook that
the Shell code opens?
Mar 9 '06 #25
Tom Becker wrote:
On 9 Mar 2006 11:39:45 -0800, CD********@FortuneJames.com wrote:


I've got the code. I'll have to pare it down to the essentials for
you. I think I monitored the activity of certain critical folders and
waited until there was no activity for a certain amount of time before
closing Outlook.

Thanks much. I would like to have that.


Here is the code you requested. Note that it is quite old and may not
utilize best practices:

'Code within some subroutine
'Initialize delay, inactivity, outbox time limit and their time window
values
intExpireMinutes = 1
lngITolerSec = 45
intInitialDelayMin = 1
lngInitialDelayTolerSec = 5
intOutLimit = 5
lngOutLimitTolerSec = 5
intOExpireMinutes = 1
lngOTolerSec = 45
'-------------------------------------------------------
'Set up Date and Time for time stamp fields
varImportDate = Format(Now, "m/d/yyyy")
varImportTime = Format(Now, "hh:nn:ss")
strToday = Format$(varImportDate, "mm/dd/yy")
'-------------------------------------------------------
'Extra information for log file
strExtra = ""

'...

'Wait intInnitialDelayMin minutes before checking for any activity
GoSub InitDelay
'-------------------------------------------------------
'Checking these folders for inactivity
Set objNameSpace = objOutlook.GetNamespace("MAPI")
'Set objTCOrders = objNameSpace.Folders.Item("Personal
Folders").Folders.Item("TCOrders")
Set objOrderReceived = objNameSpace.Folders.Item("Personal
Folders").Folders.Item("OrderReceived")
Set objOrderShipped = objNameSpace.Folders.Item("Personal
Folders").Folders.Item("OrderShipped")
Set objBackOrdered = objNameSpace.Folders.Item("Personal
Folders").Folders.Item("BackOrdered")
'Set objItems = objTCOrders.Items
Set objBackOrderedItems = objBackOrdered.Items
Set objOrderShippedItems = objOrderShipped.Items
Set objOrderReceivedItems = objOrderReceived.Items
'Don't release the objects yet. They're needed for the processing step
'-------------------------------------------------------
'Now watch the folders to determine when Outlook is done downloading
GoSub Activity
'-------------------------------------------------------
strTemp = "Done"
lblWorking.Caption = strTemp
lblStatus.Caption = "Downloading Email"
DoEvents
cmdDownloadEmail.ForeColor = RGB(255, 60, 0)
Exit Sub
'-------------------------------------------------------
'GoSub Subroutines
Activity:
'Now watch the folder to determine when Outlook is done downloading
'Start the timer
'Set the expire time to intExpireMinutes minutes in the future
varTimerExpire = DateAdd("n", intExpireMinutes, Now())
'''''intOrderItems = objItems.Count
intBackOrderedItems = objBackOrderedItems.Count
intOrderShippedItems = objOrderShippedItems.Count
intOrderReceivedItems = objOrderReceivedItems.Count
boolDone = False
strLastActivity = ""
Do While Not boolDone
DoEvents
'boolTemp = (objItems.Count = intOrderItems)
'If Not boolTemp Then strActiveIn = "TCOrders"
'boolSame = boolTemp
boolSame = True
boolTemp = (objBackOrderedItems.Count = intBackOrderedItems)
If Not boolTemp Then strActiveIn = "BackOrdered"
boolSame = boolSame And boolTemp
boolTemp = (objOrderShippedItems.Count = intOrderShippedItems)
If Not boolTemp Then strActiveIn = "OrderShipped"
boolSame = boolSame And boolTemp
boolTemp = (objOrderReceivedItems.Count = intOrderReceivedItems)
If Not boolTemp Then strActiveIn = "OrderReceived"
boolSame = boolSame And boolTemp
If boolSame Then
'Keep checking the timer
'If the current time is within lngITolerSec seconds of the Expire
Time, exit
strTemp = strLastActivity
If strTemp <> "" Then
lblWorking.Caption = strTemp
lblStatus.Caption = "Time of last activity"
DoEvents
End If
If Abs(DateDiff("s", Now(), varTimerExpire)) < lngITolerSec Then
boolDone = True
Else
strLastActivity = "Time: " & Format$(Now(), "hh:nn:ss ampm") & " "
& strActiveIn
'Reset the timer
varTimerExpire = DateAdd("n", intExpireMinutes, Now())
'Reset intOrderItems
'intOrderItems = objItems.Count
intBackOrderedItems = objBackOrderedItems.Count
intOrderShippedItems = objOrderShippedItems.Count
intOrderReceivedItems = objOrderReceivedItems.Count
strTemp = "Activity" & CStr(objItems.Count)
lblWorking.Caption = strTemp
lblStatus.Caption = "Checking inactivity"
DoEvents
End If
Loop
'At this point, there was no activity in four folders for specified
time.
Return
'-------------------------------------------------------
SendRecv:
Set MyExplorer = Nothing
Set MyExplorer = objOutlook.ActiveExplorer
MyExplorer.Activate
MyExplorer.WindowState = olMaximized
Set MyMenuBar = MyExplorer.CommandBars.Item("Standard")
Set MyMenuBarControl = MyMenuBar.Controls.Item("Send/Re&ceive")
MyMenuBarControl.Execute
Set MyMenuBar = Nothing
Return
'-------------------------------------------------------
InitDelay:
strTemp = "Waiting " & intInitialDelayMin & " min..."
lblWorking.Caption = strTemp
lblStatus.Caption = "Initial Delay"
DoEvents
varTimerExpire = DateAdd("n", intInitialDelayMin, Now())
Do While Not boolDone
DoEvents
If Abs(DateDiff("s", Now(), varTimerExpire)) <
lngInitialDelayTolerSec Then boolDone = True
Loop
strTemp = "Timing..."
lblWorking.Caption = strTemp
lblStatus.Caption = "Checking inactivity"
DoEvents
Return

'Another code snippet:
'Close Outlook 2000
'First wait until the outbox is empty

'Then wait for the Outbox count to go to zero
'!Also need a fail-safe in case emails are not sent

'When first of Time Limit, Outbox count = 0 happens, continue

varTimerExpire = DateAdd("n", intOutLimit, Now())
boolDone = False
Set objOutbox = objNameSpace.Folders.Item("Personal
Folders").Folders.Item("Outbox")
Set objOutboxItems = objOutbox.Items
intOutboxCount = objOutboxItems.Count
If intOutboxCount > 0 Then
'Click the Send/Receive button again
GoSub SendRecv
'Minimize Outlook so the user can see the activity
MyExplorer.WindowState = olMinimized
'look for activity in outbox
'Start the timer
'Set the expire time to intOExpireMinutes minutes in the future
varTimerExpire = DateAdd("n", intOExpireMinutes, Now())
intOutboxItems = objOutboxItems.Count
boolDone = False
strLastActivity = ""
strActiveIn = "Outbox"
Do While Not boolDone
DoEvents
boolTemp = (objOutboxItems.Count = intOutboxItems)
boolSame = boolTemp
If boolSame Then
'Keep checking the timer
'If the current time is within lngOTolerSec seconds of the Expire
Time, exit
strTemp = strLastActivity
If strTemp <> "" Then
lblWorking.Caption = strTemp
lblStatus.Caption = "Time of last Outbox activity"
DoEvents
End If
If Abs(DateDiff("s", Now(), varTimerExpire)) < lngOTolerSec Then
boolDone = True
Else
strLastActivity = "Time: " & Format$(Now(), "hh:nn:ss ampm") & "
" & strActiveIn
'Reset the timer
varTimerExpire = DateAdd("n", intOExpireMinutes, Now())
intOutboxItems = objOutbox.Items.Count
strTemp = "Activity " & CStr(objOutboxItems.Count)
lblWorking.Caption = strTemp
lblStatus.Caption = "Checking Outbox inactivity"
DoEvents
End If
Loop
'At this point, there was no activity in the outbox for specified
time
End If

James A. Fortune
CD********@FortuneJames.com

Mar 13 '06 #26
On 13 Mar 2006 11:33:46 -0800, CD********@FortuneJames.com wrote:
Tom Becker wrote:
On 9 Mar 2006 11:39:45 -0800, CD********@FortuneJames.com wrote:

>
>I've got the code. I'll have to pare it down to the essentials for
>you. I think I monitored the activity of certain critical folders and
>waited until there was no activity for a certain amount of time before
>closing Outlook.
>

Thanks much. I would like to have that.


Here is the code you requested. Note that it is quite old and may not
utilize best practices:

'Code within some subroutine
'Initialize delay, inactivity, outbox time limit and their time window
values
intExpireMinutes = 1
lngITolerSec = 45
intInitialDelayMin = 1
lngInitialDelayTolerSec = 5
intOutLimit = 5
lngOutLimitTolerSec = 5
intOExpireMinutes = 1
lngOTolerSec = 45
'-------------------------------------------------------
'Set up Date and Time for time stamp fields
varImportDate = Format(Now, "m/d/yyyy")
varImportTime = Format(Now, "hh:nn:ss")
strToday = Format$(varImportDate, "mm/dd/yy")
'-------------------------------------------------------
'Extra information for log file
strExtra = ""

'...

'Wait intInnitialDelayMin minutes before checking for any activity
GoSub InitDelay
'-------------------------------------------------------
'Checking these folders for inactivity
Set objNameSpace = objOutlook.GetNamespace("MAPI")
'Set objTCOrders = objNameSpace.Folders.Item("Personal
Folders").Folders.Item("TCOrders")
Set objOrderReceived = objNameSpace.Folders.Item("Personal
Folders").Folders.Item("OrderReceived")
Set objOrderShipped = objNameSpace.Folders.Item("Personal
Folders").Folders.Item("OrderShipped")
Set objBackOrdered = objNameSpace.Folders.Item("Personal
Folders").Folders.Item("BackOrdered")
'Set objItems = objTCOrders.Items
Set objBackOrderedItems = objBackOrdered.Items
Set objOrderShippedItems = objOrderShipped.Items
Set objOrderReceivedItems = objOrderReceived.Items
'Don't release the objects yet. They're needed for the processing step
'-------------------------------------------------------
'Now watch the folders to determine when Outlook is done downloading
GoSub Activity
'-------------------------------------------------------
strTemp = "Done"
lblWorking.Caption = strTemp
lblStatus.Caption = "Downloading Email"
DoEvents
cmdDownloadEmail.ForeColor = RGB(255, 60, 0)
Exit Sub
'-------------------------------------------------------
'GoSub Subroutines
Activity:
'Now watch the folder to determine when Outlook is done downloading
'Start the timer
'Set the expire time to intExpireMinutes minutes in the future
varTimerExpire = DateAdd("n", intExpireMinutes, Now())
'''''intOrderItems = objItems.Count
intBackOrderedItems = objBackOrderedItems.Count
intOrderShippedItems = objOrderShippedItems.Count
intOrderReceivedItems = objOrderReceivedItems.Count
boolDone = False
strLastActivity = ""
Do While Not boolDone
DoEvents
'boolTemp = (objItems.Count = intOrderItems)
'If Not boolTemp Then strActiveIn = "TCOrders"
'boolSame = boolTemp
boolSame = True
boolTemp = (objBackOrderedItems.Count = intBackOrderedItems)
If Not boolTemp Then strActiveIn = "BackOrdered"
boolSame = boolSame And boolTemp
boolTemp = (objOrderShippedItems.Count = intOrderShippedItems)
If Not boolTemp Then strActiveIn = "OrderShipped"
boolSame = boolSame And boolTemp
boolTemp = (objOrderReceivedItems.Count = intOrderReceivedItems)
If Not boolTemp Then strActiveIn = "OrderReceived"
boolSame = boolSame And boolTemp
If boolSame Then
'Keep checking the timer
'If the current time is within lngITolerSec seconds of the Expire
Time, exit
strTemp = strLastActivity
If strTemp <> "" Then
lblWorking.Caption = strTemp
lblStatus.Caption = "Time of last activity"
DoEvents
End If
If Abs(DateDiff("s", Now(), varTimerExpire)) < lngITolerSec Then
boolDone = True
Else
strLastActivity = "Time: " & Format$(Now(), "hh:nn:ss ampm") & " "
& strActiveIn
'Reset the timer
varTimerExpire = DateAdd("n", intExpireMinutes, Now())
'Reset intOrderItems
'intOrderItems = objItems.Count
intBackOrderedItems = objBackOrderedItems.Count
intOrderShippedItems = objOrderShippedItems.Count
intOrderReceivedItems = objOrderReceivedItems.Count
strTemp = "Activity" & CStr(objItems.Count)
lblWorking.Caption = strTemp
lblStatus.Caption = "Checking inactivity"
DoEvents
End If
Loop
'At this point, there was no activity in four folders for specified
time.
Return
'-------------------------------------------------------
SendRecv:
Set MyExplorer = Nothing
Set MyExplorer = objOutlook.ActiveExplorer
MyExplorer.Activate
MyExplorer.WindowState = olMaximized
Set MyMenuBar = MyExplorer.CommandBars.Item("Standard")
Set MyMenuBarControl = MyMenuBar.Controls.Item("Send/Re&ceive")
MyMenuBarControl.Execute
Set MyMenuBar = Nothing
Return
'-------------------------------------------------------
InitDelay:
strTemp = "Waiting " & intInitialDelayMin & " min..."
lblWorking.Caption = strTemp
lblStatus.Caption = "Initial Delay"
DoEvents
varTimerExpire = DateAdd("n", intInitialDelayMin, Now())
Do While Not boolDone
DoEvents
If Abs(DateDiff("s", Now(), varTimerExpire)) <
lngInitialDelayTolerSec Then boolDone = True
Loop
strTemp = "Timing..."
lblWorking.Caption = strTemp
lblStatus.Caption = "Checking inactivity"
DoEvents
Return

'Another code snippet:
'Close Outlook 2000
'First wait until the outbox is empty

'Then wait for the Outbox count to go to zero
'!Also need a fail-safe in case emails are not sent

'When first of Time Limit, Outbox count = 0 happens, continue

varTimerExpire = DateAdd("n", intOutLimit, Now())
boolDone = False
Set objOutbox = objNameSpace.Folders.Item("Personal
Folders").Folders.Item("Outbox")
Set objOutboxItems = objOutbox.Items
intOutboxCount = objOutboxItems.Count
If intOutboxCount > 0 Then
'Click the Send/Receive button again
GoSub SendRecv
'Minimize Outlook so the user can see the activity
MyExplorer.WindowState = olMinimized
'look for activity in outbox
'Start the timer
'Set the expire time to intOExpireMinutes minutes in the future
varTimerExpire = DateAdd("n", intOExpireMinutes, Now())
intOutboxItems = objOutboxItems.Count
boolDone = False
strLastActivity = ""
strActiveIn = "Outbox"
Do While Not boolDone
DoEvents
boolTemp = (objOutboxItems.Count = intOutboxItems)
boolSame = boolTemp
If boolSame Then
'Keep checking the timer
'If the current time is within lngOTolerSec seconds of the Expire
Time, exit
strTemp = strLastActivity
If strTemp <> "" Then
lblWorking.Caption = strTemp
lblStatus.Caption = "Time of last Outbox activity"
DoEvents
End If
If Abs(DateDiff("s", Now(), varTimerExpire)) < lngOTolerSec Then
boolDone = True
Else
strLastActivity = "Time: " & Format$(Now(), "hh:nn:ss ampm") & "
" & strActiveIn
'Reset the timer
varTimerExpire = DateAdd("n", intOExpireMinutes, Now())
intOutboxItems = objOutbox.Items.Count
strTemp = "Activity " & CStr(objOutboxItems.Count)
lblWorking.Caption = strTemp
lblStatus.Caption = "Checking Outbox inactivity"
DoEvents
End If
Loop
'At this point, there was no activity in the outbox for specified
time
End If

James A. Fortune
CD********@FortuneJames.com


Thanks for the code! It needs some adjustments to make it work but
it's a good guide to go by.
Mar 13 '06 #27

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by ~ Le Naja ~ | last post: by
40 posts views Thread by ian@kirbyfooty.com | last post: by
5 posts views Thread by Randy Harris | last post: by
3 posts views Thread by Steve | last post: by
5 posts views Thread by =?Utf-8?B?UGF1bERIQw==?= | last post: by
5 posts views Thread by =?Utf-8?B?TWFya1NraQ==?= | last post: by
2 posts views Thread by =?Utf-8?B?NWV1cm9wZWFuY3Vwcw==?= | last post: by
2 posts views Thread by =?Utf-8?B?UnVzcw==?= | last post: by
2 posts views Thread by Vighneswar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.