473,287 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Outlook Express


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

Mar 2 '06 #1
26 4448
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: ~ Le Naja ~ | last post by:
Hello evrybody, First, I hope you will understand my English because I come from Belgium ! :-) Here is what I want to know if you have the kindess to help me ! :-) I use the code above to mail...
40
by: ian | last post by:
Hi, I'm a newbie (oh no I can here you say.... another one...) How can I get Python to send emails using the default windows email client (eg outlook express)? I thought I could just do the...
5
by: Randy Harris | last post by:
I'm using the CreateObject method to send email from Access. Set objOutlook = CreateObject("Outlook.Application") This, of course, launches Outlook to send the message. Anyone know if there...
3
by: Steve | last post by:
Re: Outlook Express I'd like to get a log of the date and subject of all emails in my inbox received from sender@xyz.com and a log of the date and subject of all emails in my sentbox sent to...
5
by: =?Utf-8?B?UGF1bERIQw==?= | last post by:
Hi all, I have a customer that has Outlook and Outlook Express installed on thier PC's. I've written an app that sends emails and checks through the inbox etc to progress thier orders. This works...
5
by: =?Utf-8?B?TWFya1NraQ==?= | last post by:
For about a month now, I have had trouble with Outlook Express. When logging in to Outlook Express, I get an error message stating that the connection to server has failed. My internet connection...
2
by: =?Utf-8?B?NWV1cm9wZWFuY3Vwcw==?= | last post by:
just picked up a new laptop and want to use my main email account on this machine + my desktop. I use outlook express on the desktop and wondered whether it was possible to view my main email...
2
by: =?Utf-8?B?UnVzcw==?= | last post by:
I've been using Outlook 2000 on my XP machine forever but lately it's stopped working (Outlook has encountered an error and needs to close - Send Report). I've since made the switch to Outlook...
2
by: Vighneswar | last post by:
Hi All I am doing with a standalone application in .NET, where I have to invoke the Outlook / Outlook Express by passing account info (username, password, pop3 server, ... etc) and SQL Server...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.