# outlook out of office based on appointments



## phairplay (May 31, 2012)

is there a outlook marco that could turn on my out of office response. if I set a calandar appointment to out of office?


----------



## JP2112 (May 31, 2012)

Yes, but with some complications.

You would need to write code that checks the ReminderFire Event and determines if the reminder is associated with an appointment, and if that appointment's BusyStatus property is set to 'Out of Office'.

Ex:


```
Private WithEvents MyReminders As Outlook.Reminders
Private Sub Application_Startup()
  Set MyReminders = GetOutlookApp.Reminders
End Sub
Function GetOutlookApp() As Outlook.Application
  Set GetOutlookApp = Outlook.Application
End Function
Private Sub MyReminders_ReminderFire(ByVal ReminderObject As Reminder)
  If ReminderObject.Item.BusyStatus = 3 Then  ' out of office
' set out of office
  End If
End Sub
```
 
Visit this link for code to set OOO: Set Out Of Office programmatically

One problem is, you would need to keep Outlook open, so the reminder (and the resulting VBA) will fire. I also assume you will want to programmatically turn off OOO after the appointment is over. After setting OOO, you would probably need to set a task reminder for when the appointment ends and then write more VBA that checks for that reminder and turns off OOO.


----------

