Consulting

Results 1 to 7 of 7

Thread: Solved: Out of Office Toggle/reminder

  1. #1
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location

    Solved: Out of Office Toggle/reminder

    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/micro...56dee61ec6c391

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

    Any ideas?
    -Once my PC stopped working, so I kicked it......Then it started working again

  2. #2
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location
    no one has any ideas?
    -Once my PC stopped working, so I kicked it......Then it started working again

  3. #3
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    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


    Quote Originally Posted by OTWarrior
    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/micro...56dee61ec6c391

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

    Any ideas?

  4. #4
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location
    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.
    -Once my PC stopped working, so I kicked it......Then it started working again

  5. #5
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    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
    [vba]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 Sub[/vba]or a little modified version that turns it off.
    [vba]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 Sub[/vba]Charlize

  6. #6
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location
    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.


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

    [VBA]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[/VBA]
    Last edited by OTWarrior; 07-24-2009 at 02:58 AM.
    -Once my PC stopped working, so I kicked it......Then it started working again

  7. #7
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •