.Find fails for .Outlook._Items

S

S.Clark

[I put this in .general, but was specifically requested to repost here.]

Using VB.NET:

The last line of this code errors out. Any clues?

oApp = New Microsoft.Office.Interop.Outlook.Application()
oNS = oApp.GetNamespace("MAPI")
oNS.Logon(Missing.Value, Missing.Value, True, True)

Dim oCt As Microsoft.Office.Interop.Outlook.ContactItem
Dim objconts As Microsoft.Office.Interop.Outlook._Items = targetFolder.Items

oCt = objconts.Find("[CustomerID]='" & strID & "'")

===

Error Info:
Message = "The operation failed"
ErrorCode = -142589947
 
J

Jan Hyde (VB MVP)

S.Clark <[email protected]>'s wild thoughts
were released on Thu, 16 Oct 2008 12:13:03 -0700 bearing the
following fruit:
[I put this in .general, but was specifically requested to repost here.]

Using VB.NET:

The last line of this code errors out. Any clues?

oApp = New Microsoft.Office.Interop.Outlook.Application()
oNS = oApp.GetNamespace("MAPI")
oNS.Logon(Missing.Value, Missing.Value, True, True)

Dim oCt As Microsoft.Office.Interop.Outlook.ContactItem
Dim objconts As Microsoft.Office.Interop.Outlook._Items = targetFolder.Items

oCt = objconts.Find("[CustomerID]='" & strID & "'")

Try

oCt = objconts.Find("[CustomerID]= " & Chr$(34) & strID &
Chr$(34))
 
J

Jan Hyde (VB MVP)

"Jan Hyde (VB MVP)" <[email protected]>'s
wild thoughts were released on Fri, 17 Oct 2008 09:16:23
+0100 bearing the following fruit:
S.Clark <[email protected]>'s wild thoughts
were released on Thu, 16 Oct 2008 12:13:03 -0700 bearing the
following fruit:
[I put this in .general, but was specifically requested to repost here.]

Using VB.NET:

The last line of this code errors out. Any clues?

oApp = New Microsoft.Office.Interop.Outlook.Application()
oNS = oApp.GetNamespace("MAPI")
oNS.Logon(Missing.Value, Missing.Value, True, True)

Dim oCt As Microsoft.Office.Interop.Outlook.ContactItem
Dim objconts As Microsoft.Office.Interop.Outlook._Items = targetFolder.Items

oCt = objconts.Find("[CustomerID]='" & strID & "'")

Try

oCt = objconts.Find("[CustomerID]= " & Chr$(34) & strID &
Chr$(34))

Oops

Set oCt = etc
 
K

Ken Slovak - [MVP - Outlook]

No Set for VB.NET code.




Jan Hyde (VB MVP) said:
"Jan Hyde (VB MVP)" <[email protected]>'s
wild thoughts were released on Fri, 17 Oct 2008 09:16:23
+0100 bearing the following fruit:
S.Clark <[email protected]>'s wild thoughts
were released on Thu, 16 Oct 2008 12:13:03 -0700 bearing the
following fruit:
[I put this in .general, but was specifically requested to repost here.]

Using VB.NET:

The last line of this code errors out. Any clues?

oApp = New Microsoft.Office.Interop.Outlook.Application()
oNS = oApp.GetNamespace("MAPI")
oNS.Logon(Missing.Value, Missing.Value, True, True)

Dim oCt As Microsoft.Office.Interop.Outlook.ContactItem
Dim objconts As Microsoft.Office.Interop.Outlook._Items =
targetFolder.Items

oCt = objconts.Find("[CustomerID]='" & strID & "'")

Try

oCt = objconts.Find("[CustomerID]= " & Chr$(34) & strID &
Chr$(34))

Oops

Set oCt = etc
 
A

Alan Moseley

Your code looks correct. It looks to me like you may have 'Folder Visible'
permissions on the target folder but maybe not 'Read Items'.
 

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