Check "Out of Office" Status of Outlook Contact - VBA

screech

Active Member
Joined
May 27, 2004
Messages
296
Hello all,

I am wondering if it is possible to write a section of VBA code in an Excel workbook that will determine the Outlook "Out of Office" status of a contact within the company. I have a list of employee names that match the name in the Outlook Address Book. I would like to be able to check the name of each employee to see if they have their Outlook set up for "Out of Office". Is there a section of VBA code that can be put into an Excel workbook to pull that information from an Outlook server or network or something? Like a True/False?

I am using Office 2010 Professional Plus products for Excel and Outlook.

Thank you very much for any help. Searches in this form and on the internet don't seem to have what I am looking for, or maybe I can't find it. Any guidance would be appreciated.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
This might be a start, but you will have to figure out how to send another employees name as it only checks your own mailboxes:

Code:
Sub Check_Out_Of_Office()
Dim oNS As Outlook.Namespace
Dim oStores As Outlook.Stores
Dim oStr As Outlook.Store
Dim oPrp As Outlook.PropertyAccessor
Set oNS = Outlook.GetNamespace("MAPI")
Set oStores = oNS.Stores
For Each oStr In oStores
If oStr.ExchangeStoreType = olPrimaryExchangeMailbox Then
Set oPrp = oStr.PropertyAccessor
MsgBox oPrp.GetProperty(http://schemas.microsoft.com/mapi/proptag/0x661D000B)
End If
Next

End Sub
I'm going to try to see if I can find anything about other mailboxes, but theOutlook.GetNamespace("MAPI") line I believe is only good for your current session and I am not sure what to use for like a company directory.
 
Last edited:
Upvote 0
Code:
Sub Check_Out_Of_Office()
Dim oNS As Outlook.Namespace
Dim oStores As Outlook.Stores
Dim oStr As Outlook.Store
Dim oPrp As Outlook.PropertyAccessor
Set oNS = Outlook.GetNamespace("MAPI")
Set oStores = oNS.Stores
For Each oStr In oStores
If oStr.ExchangeStoreType = olPrimaryExchangeMailbox Then
Set oPrp = oStr.PropertyAccessor
MsgBox oPrp.GetProperty(http://schemas.microsoft.com/mapi/proptag/0x661D000B)
End If
Next

End Sub

This is a good start. I actually plugged that code into a module and it is returning my out of office status correctly as true/false. I have also found some code that appears to retrieve my list of contacts although I haven't actually tried it out. But this Check_Out_of_Office code doesn't seem to have a lot of variables to it or anywhere else to plug in a contact name. I have looked around some more into how to get other user's namespace information but I haven't found anything yet.
 
Upvote 0
This is a good start. I actually plugged that code into a module and it is returning my out of office status correctly as true/false. I have also found some code that appears to retrieve my list of contacts although I haven't actually tried it out. But this Check_Out_of_Office code doesn't seem to have a lot of variables to it or anywhere else to plug in a contact name. I have looked around some more into how to get other user's namespace information but I haven't found anything yet.

I too want to create a list of person's at my company who have turned on Automatic Replies (out of office). I'm amazed that I haven't been able to google my way to more info about this. There doesn't seem to be a solution. Were you able to learn more?...JD
 
Upvote 0

Forum statistics

Threads
1,222,550
Messages
6,166,725
Members
452,066
Latest member
the_rizzler

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top