Get error "Object could not be found" during Items.Add()

J

Jeff

I'm getting the error "Object could not be found" (-2147221233) when adding to
a folder I created. I suspect it's caused by a missing form, but can't tell.
If not a missing form, then what?!! I've read everything I can find on forms
cache, publishing forms, folder solutions.

Additional facts:

- Folder is currently empty
- Folder is non-public (in a private mailbox)
- Using Exchange 2000 Enterprise SP3
- Folder is a task folder with additional fields (text, yes/no, datetime)
- Am attempting to add "IPM.Task.MyType" item
- This folder has NO forms associated with it
- We DO have an organization forms collection (I believe should be unrelated)
- By default, I use an HTML page with custom controls to display folder items
- Can successfully add vanilla IPM.Task items to folder using standard task
form
- Can successfully add "IPM.Task.MyType" items in C++ going through MAPI
- Have deleted and re-created folder...no effect
- Some users have no error; others do. (Users are on different Exchange
servers)
- Folder is not top-level: have folder structure like:
+ Mailbox
- MyFolders
- ProblemFolder

Here's the code (I've omitted successful setup code, functions, and error
checks)

Dim objFolder As MAPIFolder
Dim otlTasks As Items
Dim otlItems As Object
Dim otlItem As Object

Set objFolder = m_otlNamespace.GetFolderFromID(strMyFolderID)
Set otlTasks = objFolder.Items
Set otlTasks = otlTasks.Restrict("[CustomTextField]=sometext")
Set otlItems = otlTasks ' Keep reference for future use
Set otlTasks = Nothing
Set objFolder = Nothing

If otlItems.Count = 0 Then
'THIS IS THE LINE THAT THROWS THE ERROR
Set otlItem = otlItems.Add("IPM.Task.MyType")
....


Thanks in advance for any help or suggestions of things I can investigate!
 
S

Sue Mosher [MVP]

Does it work if you don't Set objFolder = Nothing and you use this
statement:

Set otlItem = objFolder.Items.Add("IPM.Task.MyType")
 
J

Jeff

Thanks for the quick reply. I still had the problem after trying your idea, but
your suggestion caused me to try something else that did work:

Set otlItem = otlItems.Add
otlItem.MessageClass = "IPM.Task.MyType"

This works for me because I have no forms for MyType (need no forms processing
when creating the item)

I don't know why some versions of Outlook report this as an error while
others do not. But since my fix works, I'm not too worried about it :)

Sue Mosher said:
Does it work if you don't Set objFolder = Nothing and you use this
statement:

Set otlItem = objFolder.Items.Add("IPM.Task.MyType")

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Jeff said:
I'm getting the error "Object could not be found" (-2147221233) when adding to
a folder I created. I suspect it's caused by a missing form, but can't tell.
If not a missing form, then what?!! I've read everything I can find on forms
cache, publishing forms, folder solutions.

Additional facts:

- Folder is currently empty
- Folder is non-public (in a private mailbox)
- Using Exchange 2000 Enterprise SP3
- Folder is a task folder with additional fields (text, yes/no, datetime)
- Am attempting to add "IPM.Task.MyType" item
- This folder has NO forms associated with it
- We DO have an organization forms collection (I believe should be unrelated)
- By default, I use an HTML page with custom controls to display folder items
- Can successfully add vanilla IPM.Task items to folder using standard task
form
- Can successfully add "IPM.Task.MyType" items in C++ going through MAPI
- Have deleted and re-created folder...no effect
- Some users have no error; others do. (Users are on different Exchange
servers)
- Folder is not top-level: have folder structure like:
+ Mailbox
- MyFolders
- ProblemFolder

Here's the code (I've omitted successful setup code, functions, and error
checks)

Dim objFolder As MAPIFolder
Dim otlTasks As Items
Dim otlItems As Object
Dim otlItem As Object

Set objFolder = m_otlNamespace.GetFolderFromID(strMyFolderID)
Set otlTasks = objFolder.Items
Set otlTasks = otlTasks.Restrict("[CustomTextField]=sometext")
Set otlItems = otlTasks ' Keep reference for future use
Set otlTasks = Nothing
Set objFolder = Nothing

If otlItems.Count = 0 Then
'THIS IS THE LINE THAT THROWS THE ERROR
Set otlItem = otlItems.Add("IPM.Task.MyType")
...


Thanks in advance for any help or suggestions of things I can investigate!
 

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