PDA

View Full Version : Solved: Out of Office Toggle/reminder



OTWarrior
05-27-2009, 02:54 AM
I often have a Thursday afternoon off, so turn on my out of office (OOO) on. I have to leave my PC on all the time to do backups, including outlook, as this sends me an email telling me if the backup is successful or not to my home email.

Due to leaving outlook open, when I arrive on Friday morning, I do not get a prompt telling me OOO is still on. Is there anyway of finding out the value of the and displaying a message? or automatically changing OOO's value via a macro? or calendar event?

I have searched, and so far the only indicators I can find are using the CDO reference and MAPI controls, or building something into the exchange server (which is not something I can do, as I only have access to client side resources)

This is the only useful page I have found:
http://groups.google.com/group/microsoft.public.outlook.program_vba/browse_thread/thread/7d33994a4c1d9064?hl=en&q=Out+of+Office+automation#9756dee61ec6c391

But there is no guide as to how to use the CDO controls.

Any ideas?

OTWarrior
06-17-2009, 01:04 AM
no one has any ideas?

JP2112
06-17-2009, 06:29 PM
Just set up an Outlook task reminder for Friday mornings (recurrence: every 1 week on Fridays) reminding you to check if your OOO should be turned off.

--JP



I often have a Thursday afternoon off, so turn on my out of office (OOO) on. I have to leave my PC on all the time to do backups, including outlook, as this sends me an email telling me if the backup is successful or not to my home email.

Due to leaving outlook open, when I arrive on Friday morning, I do not get a prompt telling me OOO is still on. Is there anyway of finding out the value of the and displaying a message? or automatically changing OOO's value via a macro? or calendar event?

I have searched, and so far the only indicators I can find are using the CDO reference and MAPI controls, or building something into the exchange server (which is not something I can do, as I only have access to client side resources)

This is the only useful page I have found:
http://groups.google.com/group/microsoft.public.outlook.program_vba/browse_thread/thread/7d33994a4c1d9064?hl=en&q=Out+of+Office+automation#9756dee61ec6c391

But there is no guide as to how to use the CDO controls.

Any ideas?

OTWarrior
06-22-2009, 01:47 AM
I was wanting to do it more as an automated macro, that way if I have been out of the office on a Tuesday (for example) then it will prompt me the day after.

Yes, I can set reminders up, but I would rather not have more tasks in my calendar.

Plus, I am curious how to reference the OOO commands in vb.

Charlize
06-22-2009, 04:12 AM
Maybe this could help solving your problem. When you start-up outlook in the morning you could run an additional script that looks at the day. If it's friday, do a on time script to run a certain macro (ie. on monday 8 am run the macro that inform's you that out of office is still on). The only downside is that you have to put a reference to the cdo library
Sub test_out_of_office()
'You need a reference to cdo 1.21 library
Dim oCDO As MAPI.Session
Dim oStore As MAPI.InfoStore
Dim oFolder As MAPI.Folder
Dim strStoreID As String
Dim blnOOF As Boolean
Set oCDO = CreateObject("MAPI.Session")
oCDO.Logon "", "", False, False 'piggy-back logon
Set oFolder = oCDO.Inbox 'get default Inbox
strStoreID = oFolder.StoreID 'get default InfoStore.StoreID0
Set oStore = oCDO.GetInfoStore(strStoreID) 'get store
'Next line doesn't work in 2003
'blnOOF = oStore.Fields(&H661D000B) 'get property
'This line does work.
blnOOF = oCDO.OutOfOffice
If blnOOF = False Then
MsgBox "Out Of Office is off."
Else
MsgBox "Out of Office in on."
End If
End Subor a little modified version that turns it off.
Sub test_out_of_office()
'You need a reference to cdo 1.21 library
'... Previous coding

If blnOOF = False Then
MsgBox "Out Of Office is off."
Else
MsgBox "Out of Office in on."
'Turn it off
oCDO.OutOfOffice = False
'As an extra check up
MsgBox "Out Of Office = " & oCDO.OutOfOffice
End If
End SubCharlize

OTWarrior
07-24-2009, 02:46 AM
I have come up with a solution to my problem, and it works rather well.

Note: You need to leave the computer on, and set up a rule in Outlook to read messages when they arrive, check for a particular email sender (to make sure it only happens when you want it), as well as your chosen subject and to run the macro

Project1.ThisOutlookSession.Checker
and
Project1.ThisOutlookSession.OOO_Status

(the first one will change the status, the second one will just report back the status)


Also need a reference to the CDO libary in VB (Tools>References)

The 3 macros are separated for ease of understanding which is which. The word EMAIL is the personal email address you need to put in.


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

Sub Checker(Item As Outlook.MailItem)
On Error GoTo err1
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False
Dim oocheck As String
Dim emailText As String

oSession.OutOfOffice = Not oSession.OutOfOffice

emailText = "Line 1 " & vbCrLf & _
"Line 2" & vbCrLf & _
"Line 3" & vbCrLf & _
"Line 4" & vbCrLf & _
"Line 5" & vbCrLf & vbCrLf & _
"Regards" & vbCrLf & "NAME"

oocheck = oSession.OutOfOffice

If oocheck = "True" Then
oSession.OutOfOfficeText = emailText
Call SendEmail("OOO status - " & oocheck, "Out of Office is now on", "EMAIL", False)
ElseIf oocheck = "False" Then
Call SendEmail("OOO status - " & oocheck, "Out of Office is now turned off", "EMAIL", False)
Else
GoTo err1
End If

Exit Sub

err1:
MsgBox Err.Description
End Sub

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

Sub OOO_Status(Item As Outlook.MailItem)
On Error GoTo err1
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False
Dim oocheck As String

oocheck = oSession.OutOfOffice

If oocheck = "True" Then
Call SendEmail("OOO status - " & oocheck, "Out of Office is turned on", "EMAIL", False)
ElseIf oocheck = "False" Then
Call SendEmail("OOO status - " & oocheck, "Out of Office is turned off", "EMAIL", False)
Else
GoTo err1
End If

Exit Sub

err1:
MsgBox Err.Description
End Sub


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

Public Sub SendEmail(strSUBJ As String, strMsg As String, Optional strTO As String, Optional Show As Boolean)
Dim oMI As Outlook.MailItem
Dim oReply As Outlook.MailItem
Set oReply = Outlook.CreateItem(olMailItem)
On Error GoTo err1

oReply.To = strTO
oReply.Subject = strSUBJ
oReply.HTMLBody = strMsg

If Show = True Then
oReply.Display
Else
oReply.Send
End If

Exit Sub

err1:
MsgBox Err.Description
End Sub

junglej815
01-06-2010, 11:49 AM
Hello,

Just curious, would something like this be usable for having an Out of Office "turn on" automatically on every Saturday at 4:00pm and "turn off" automatically on every Wednesday at 5:30am?