See if outlook is running during access program execution

G

Guest

Can anyone help me? I need a way for access to verify if outlook is running
when my database program is started. I have an access database for my
tooling. The operator starts the db program from an Icon when he needs a tool
and completes a transaction. When a minimum level is reached the db sends an
email to purchasing to order more tools. When the transaction is complete he
closes the application. I'm sharing this computer with other departments so
leaving the application on is not an option. The other departments don't use
the inbox and it keeps getting shutoff "accidently"! If outlook isn't on when
a transaction takes place, it won't send the email. I need to turn it on
automatically which I can do with the shell command. The problem is if it is
currently running. It opens up a second, and third, ..etc inbox window. Is
there a way to to either hide outlook while it's running or verify whether
the inbox is on or not so I can get this application to work correctly and
flawlessly. Any help would be appreciated. I don't have much hair left to
pull out!
 
D

David C. Holley

So when the .Send method of the MailItem is just putting the item in the
INBOX as opposed to actually sending it? What is the code that you're
using to create the MailItem?
 
D

Dirk Goldgar

Gunner said:
Can anyone help me? I need a way for access to verify if outlook is
running when my database program is started. I have an access
database for my tooling. The operator starts the db program from an
Icon when he needs a tool and completes a transaction. When a minimum
level is reached the db sends an email to purchasing to order more
tools. When the transaction is complete he closes the application.
I'm sharing this computer with other departments so leaving the
application on is not an option. The other departments don't use the
inbox and it keeps getting shutoff "accidently"! If outlook isn't on
when a transaction takes place, it won't send the email. I need to
turn it on automatically which I can do with the shell command. The
problem is if it is currently running. It opens up a second, and
third, ..etc inbox window. Is there a way to to either hide outlook
while it's running or verify whether the inbox is on or not so I can
get this application to work correctly and flawlessly. Any help would
be appreciated. I don't have much hair left to pull out!

You could use a function like this to determine if Outlook is running or
not:

'----- start of code -----
Function IsOutlookRunning() As Boolean

Dim objOutlook As Object

On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")

If objOutlook Is Nothing Then
IsOutlookRunning = False
Else
IsOutlookRunning = True
Set objOutlook = Nothing
End If

End Function

'----- end of code -----

Note: it would probably be better to check the error that might be
raised by the call to GetObject, in case there's some other error than
429, "ActiveX component can't create object". But this is just a quick,
knock-off function, and probably if you don't get an Outlook Application
object back from GetObject, that's all you really need to know.
 
G

Guest

Dirk Goldgar said:
You could use a function like this to determine if Outlook is running or
not:

'----- start of code -----
Function IsOutlookRunning() As Boolean

Dim objOutlook As Object

On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")

If objOutlook Is Nothing Then
IsOutlookRunning = False
Else
IsOutlookRunning = True
Set objOutlook = Nothing
End If

End Function

'----- end of code -----

Note: it would probably be better to check the error that might be
raised by the call to GetObject, in case there's some other error than
429, "ActiveX component can't create object". But this is just a quick,
knock-off function, and probably if you don't get an Outlook Application
object back from GetObject, that's all you really need to know.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Dirk, The code you recommended worked great! I even have a few hairs left on my head for the next project. Thanks again, I'll reply to the news group. It's is really appreciated. Gunner
 

Ask a Question

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

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

Ask a Question

Top