View Single Post
  #10  
Old November 22nd 06, 12:06 AM posted to microsoft.public.outlook.program_vba
Brian Hampson
external usenet poster
 
Posts: 6
Default Coding against Out Of Office in Outlook 2007

I went the Redemption route, and the registerless COM. It's all good I
suppose.

I was hoping to avoid 3rd party products.

It works, and since I'm the customer - I'll sign off on it

Ken Slovak - [MVP - Outlook] wrote:
Getting a folder using GetSharedDefaultFolder doesn't really give you all
the properties, permissions and so on that you need for a lot of things. If
the store is opened as part of your Outlook profile you should be able to
iterate the Stores collection and get the Inbox for each Exchange type
store. That might work.

Other than that? I'd be using Redemption code myself. There are a number of
limitations with PropertyAccessor such as memory errors if you exceed a
certain limit in retrieving data from a PT_STRING8, PT_BINARY and PT_Unicode
property. What those limits are is still open to discovery. They didn't
implement a fall-back to an IStream if getting the property normally fails.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Brian Hampson" wrote in message
ups.com...
Hi Ken. Thanks for all your directions so far. I seem to have my "Out
of Office Tool" working when I use my own mailbox presently... Not so
much when I choose another user. (Note, when I was using MAPI, this
was working fine.... now I seem to have some sort of Perm issue)

Here's my code:

Outlook.ApplicationClass app = new
Microsoft.Office.Interop.Outlook.ApplicationClass( );
Outlook.NameSpaceClass ns =
(Outlook.NameSpaceClass)app.GetNamespace("MAPI");
Outlook.Recipient recipient =
ns.CreateRecipient(this.mailboxtxt.Text);

if (recipient.Resolve())

{
Outlook.MAPIFolder Inbox =
ns.GetSharedDefaultFolder(recipient,
Outlook.OlDefaultFolders.olFolderInbox);
Outlook.PropertyAccessor pa = Inbox.PropertyAccessor;
foreach (Outlook.Store store in ns.Stores)
{
if (store.ExchangeStoreType ==
Outlook.OlExchangeStoreType.olPrimaryExchangeMailb ox)
OOFState =
(bool)store.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x661D000B");
}

Outlook.StorageItem OOFMessage;
OOFMessage =
Inbox.GetStorage("IPM.Note.Rules.OofTemplate.Micro soft",

Outlook.OlStorageIdentifierType.olIdentifyByMessag eClass);
this.checkBoxIn.Checked = !OOFState;
this.OOOtxt.Text = OOFMessage.Body;
}

When I do the Inbox.GetStorage on another user's mailbox, I now get:

"An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in
OutOfOffice.exe"

"Additional information: Cannot create StorageItem in this folder.
Either the folder is read-only, or a storage item is not allowed in
this folder. "

Any ideas? Thanks for your patience. I don't know HOW this is
supposed to be better than the old way


Ads