Outlook 2007 - Getting Note Body

G

Guest

With Access & Outlook 2003 I had Access code that read through the Notes
folder with
Dim fldFolder As Outlook.MAPIFolder
Dim objItems As Items
Dim objItem As Object
Dim oNoteItem as As Outlook.NoteItem
Set fldFolder =
Outlook.Application.GetNamespace("MAPI").GetDefaultFolder(olFolderNotes)
Set objItems = fldFolder.Items
objItems.Sort "Subject"
For Each objItem In objItems
Set oNoteItem = objItem
<... then code to use oNoteItem.Body, oNoteItem.Subject>

But this same code fails on the fldFolder.Items with Access/Outlook 2007.
Run-time error 80040155, Method "Items' of object MAPIFolder failed.

What is the correct coding style for accessing/modify Notes with 2007. A
pointer to Knowledge base article would be appreciated. I've trying replacing
the above style with using the new Table object but can't find a way to get a
"Body" column. The default columns contain only Subject. Columns.RemoveAll
followed by Columns.Add ("Body") fails.

Hints, pointers to overviews on handling issues of Access/Outlook 2003->2007
vba conversion would be appreciated.

Daniel
 
K

Ken Slovak - [MVP - Outlook]

I wouldn't expect to be able to use anything much with Notes and have it
work, they're brain dead and have been since Outlook 97. Just stick with the
normal exposed properties for a Note item and you should be OK. Trying to do
anything fancy with Notes is a waste of time.
 
G

Guest

Even though Note "have been brain dead since Outlook 97" ... I still have a
need to be able to read/edit/create Notes (Contacts, Mail Items) in Outlook
2007 using VBA code in Access 2007.

I've read that MAPIFolder no longer exists in the Outlook 12.0 Object
library and has been replaced by Outlook.Folder. But I still can't seem to
find a way to get to the items in a notes folder.

Dim oFld as Outlook.Folder
Set oFld =
Outlook.Application.GetNamespace("MAPI").GetDefaultFolder(olFolderNotes)

seem to get me a valid oFld object. II add it to the watch window and set a
break point after the above code and the object looks fine. It has the
correct number of Items in the watch window but

dim oItems as Items
Set oItems = oFld.Items

crashes.

What am I doing wrong? Where can I find code example for read/edit/create
Outlook 2007 mail, note, contact items using vba code from an Access 2007?

Daniel
 
S

Sue Mosher [MVP-Outlook]

Your code ran fine here in Access 2007 after I fixed the typo in the NoteItem declaration. Outlook was already running.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Thanks for the reply (looking forward to release of your 2007 book).

I'm still having problems. The code below in Access 2007
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.Folder
Dim olItems As Items

Set olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olFolder = olNS.GetDefaultFolder(olFolderNotes)
Set olItems = olFolder.Items

throws an "interface not found" on olFolder.Items for Inbox and Notes
folders. I'm running Vista Home Premium, Office 2007 ultimate. Pretty
straight forward but can't seem to get it to work. I'm trying to find a way
to do simple read/edit/create/delete using Items on the default notes and
contacts folders. I know the Table feature is the preferred way to get to
data but I think I need to use Items for notes since the body is RTF and
Table does not support an RTF column.

Daniel
 
S

Sue Mosher [MVP-Outlook]

Did you try it with Outlook already running? That would be useful for troubleshooting this. It also wouldn't hurt to run Office Diagnostics and turn off any anti-virus application.

The Body doesn't return RTF content for any object, BTW.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Thanks for all your responses. Using the clue that things worked for you ...
I tried doing a "repair" of my Office installation and then ... presto ...
the Items interface is now registered and I'm able to process notes.

Thanks for the clue ... awaiting your book at my local bookstore.

Consider this closed. Happy long weekend.

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top