Type Mismatch

Set body = doc.GetFirstItem(“Body”)Forall attach In body.EmbeddedObjects

Why is the second line above giving me a type mismatch whenever the document contains a document link only. If the document has an attachment and link, or attachment only, or no link or attachment no error is generated.

I have declared attach as NotesEmbeddedObject or Variant and same error

Subject: Type Mismatch

Try

Set body = doc.GetFirstItem(“Body”)

If IsArray(body.EmbeddedObjects ) then

Forall attach In body.EmbeddedObjects

End ForAll

End if

Subject: Type Mismatch

Hassan,

I do not believe that a native Notes doc link is considered an embedded object. (As a matter of fact, the Help documentation states that it is a rich text element accessible from a NotesRichTextNavigator.

I wonder if you are getting a type mismatch based off the body variable and not on the attach variable. How is the body variable dimmed–as a NotesRichTextItem or a variant?

brandt

Subject: RE: Type Mismatch

body was declared as Variant

Subject: RE: Type Mismatch

Hassan,

That’s what I figured…you are going to have to test your body variable to make sure you have a NotesRichTextItem…otherwise, you are going to see behavior like this.

Try adding this line after setting the body variable:

If body.Type = RICHTEXT then

(do your check for embedded objects here)

End If

now as I stated in my earlier post…LS doesn’t consider a doc link an embedded object, and to test for it, you’ll need to use a combination of the NotesRichTextNavigator and NotesRichTextDocLink objects to do the test.

brandt

Subject: RE: Type Mismatch

We did that but still got the same error…Testing IsArray(body.EmbeddedObjects) seems to have done the trick.

Subject: RE: Type Mismatch

body.EmbeddedObjects property recognises only file attachments, object links, and embedded objects But not the doclink which you mentioned in your previous posting. Hence the error.

This way you can find doclink:

Dim rtnav As NotesRichTextNavigator

Dim rtlink As NotesRichTextDocLink

dim dclnk as integer

Set body = doc.GetFirstItem(“Body”)

Set rtnav = body.CreateNavigator

Set rtlink = rtnav.GetFirstElement(RTELEM_TYPE_DOCLINK)

dclnk = False

Do until dclnk = True

if rtlink is nothing then

   Set rtlink = rtnav.GetNextElement

else

   dclnk = True

   exit do

end if

Loop

if dclnk then msgbox “doclink exists”