Outlook 2007: How to read/write Out-of-Office settings

  • Thread starter VGhvbWFz
  • Start date Views 2,806
V

VGhvbWFz

#1
For Outlook 2003 the CDO 1.21 was available to manipulate the out-of-office

settings of an Exchange account. How to do this with Outlook 2007?
 
K

Ken Slovak - [MVP - Outlook]

#2
You can still do that with Outlook 2007 using CDO 1.21, you just need to

download CDO from the MS Web site. It's no longer included on the Office CD.

To use the new object model properties in Outlook 2007 you would still look

for a hidden item with a MessageClass of

"IPM.Note.Rules.OofTemplate.Microsoft". To get to the hidden items

collection you would use Folder.GetStorage(), supplying the MessageClass as

the StorageIdentifier argument and

OlStorageIdentifierType.olIdentifyByMessageClass as the

StorageIdentifierType argument.

For any properties you want that aren't exposed to the Outlook object model

you would use the item.PropertyAccessor() object to access those properties.

For that you would use the DASL property tag of the property you want.

"Thomas" <Thomas> wrote in message

news:95503438-E32D-43BA-8E2C-03B38B91E422@microsoft.com...
> For Outlook 2003 the CDO 1.21 was available to manipulate the
> out-of-office
> settings of an Exchange account. How to do this with Outlook 2007?
 
V

VGhvbWFz

#3
Dear Ken,

thank you very much for your response.

I have created the following code snipped from it:

Dim oInbox As Outlook.Folder

Set oInbox = Application.Session.GetDefaultFolder(olFolderInbox)

' Get an instance of the hidden StorageItem

Dim oStorageItem As Outlook.StorageItem

Set oStorageItem =

oInbox.GetStorage("IPM.Note.Rules.OofTemplate.Microsoft",

olIdentifyByMessageClass)

' Manipulate settings

oStorageItem.PropertyAccessor.SetProperty

"http://schemas.microsoft.com/mapi/proptag/0x661D000B", True

oStorageItem.Body = strOutOfOfficeText

oStorageItem.Save

' Cleanup

Set oStorageItem = Nothing

Set oFolder = Nothing

The line containing the call to SetProperty does not work. Probalbly it's

the wrong property tag. Which property tag is the correct one to switch on

the out-of-office reply?

Is oStorageItem.Body the correct place to enter the text of the out-of

-office reply?

Thank you very much!

Thomas
wrote:


> You can still do that with Outlook 2007 using CDO 1.21, you just need to
> download CDO from the MS Web site. It's no longer included on the Office CD.

> To use the new object model properties in Outlook 2007 you would still look
> for a hidden item with a MessageClass of
> "IPM.Note.Rules.OofTemplate.Microsoft". To get to the hidden items
> collection you would use Folder.GetStorage(), supplying the MessageClass as
> the StorageIdentifier argument and
> OlStorageIdentifierType.olIdentifyByMessageClass as the
> StorageIdentifierType argument.

> For any properties you want that aren't exposed to the Outlook object model
> you would use the item.PropertyAccessor() object to access those properties.
> For that you would use the DASL property tag of the property you want.

> >

>

> "Thomas" <Thomas> wrote in message
> news:95503438-E32D-43BA-8E2C-03B38B91E422@microsoft.com...
> > For Outlook 2003 the CDO 1.21 was available to manipulate the
> > out-of-office
> > settings of an Exchange account. How to do this with Outlook 2007?


>
 
K

Ken Slovak - [MVP - Outlook]

#4
What you retrieved from the hidden items of Inbox is the OOF template form.

What you are trying to do is set the OOFState property (PR_OOF_STATE =

0x661D000B) on that form, where it doesn't exist.

That property exists in the mailbox Store object and is set True to set OOF

and False to cancel OOF. Your DASL property tag is absolutely correct,

you're just trying to set it on the wrong object.

BTW, for ease of debugging I'd recommend using an explicit PropertyAccessor

object, as in:

Dim oProp As Outlook.PropertyAccessor

Set oProp = object.PropertyAccessor 'and so on

For what you want the code would run something like this:

Dim oStore As Outlook.Store

Set oStore = Application.Session.DefaultStore

If oStore.ExchangeStoreType = olPrimaryExchangeMailbox Then

' only with default (primary) mailbox

Dim oProp As Outlook.PropertyAccessor

Set oProp = oStore.PropertyAccessor

' set OOFState = true

oProp.SetProperty

"http://schemas.microsoft.com/mapi/proptag/0x661D000B", True

End If

See if that works any better.

To set the OOF message you would use the Body property of the StorageItem

you retrieved for the OOF template.

"Thomas" <Thomas> wrote in message

news:CEB85BFD-D773-46AF-BF63-ED4E45FF96F4@microsoft.com...
> Dear Ken,

> thank you very much for your response.
> I have created the following code snipped from it:

> Dim oInbox As Outlook.Folder
> Set oInbox =
> Application.Session.GetDefaultFolder(olFolderInbox)

> ' Get an instance of the hidden StorageItem
> Dim oStorageItem As Outlook.StorageItem
> Set oStorageItem =
> oInbox.GetStorage("IPM.Note.Rules.OofTemplate.Microsoft",
> olIdentifyByMessageClass)

> ' Manipulate settings
> oStorageItem.PropertyAccessor.SetProperty
> "http://schemas.microsoft.com/mapi/proptag/0x661D000B", True
> oStorageItem.Body = strOutOfOfficeText
> oStorageItem.Save

> ' Cleanup
> Set oStorageItem = Nothing
> Set oFolder = Nothing

> The line containing the call to SetProperty does not work. Probalbly it's
> the wrong property tag. Which property tag is the correct one to switch
> on
> the out-of-office reply?

> Is oStorageItem.Body the correct place to enter the text of the out-of
> -office reply?

> Thank you very much!
> Thomas
 

Similar threads

Top