notesRichTextItem.EmbedObject help

I am trying to attach a pdf file to a document via lotusscript.

I am uploading the file using the following:

Dim rt As notesrichtextitem

Dim embedOb As NotesEmbeddedObject

'myDoc is currentDocument, Attachment is rich text field

Set rt = myDoc .GetFirstItem( “Attachment” )

'myText is the pdf to uplaod

Set embedOb = rt.EmbedObject (EMBED_ATTACHMENT, “”, “c:\data\mytext.pdf”)

The problem is it does not attach the file itself, but instead adds the contents of the pdf file. It displays just a load of jumbled data. Does anyone know how to just attach a pdf to a rich text field, rather than the contents of it?

Thanks

PS The same thing happens if I use EMBED_OBJECT.

Subject: notesRichTextItem.EmbedObject help

Did you try this instead?

embedOb = rt.EmbedObject (1454, “”, “c:\data\mytext.pdf”)

Subject: RE: notesRichTextItem.EmbedObject help

Have tried that and get the same problem. This is what it puts in the rich text field:

%PDF-1.2

%âãÏÓ

4 0 obj

<<

/Linearized 1

/O 6

/H [ 734 170 ]

/L 95280

/E 93687

/N 1

/T 95083

endobj

                                                         xref

4 16

0000000016 00000 n

0000000664 00000 n

0000000904 00000 n

0000001055 00000 n

0000001248 00000 n

etc etc

Has anyone else experienced this with attachments? The files open ok. They aren’t corrupt. Just wont attach/embed.

Subject: RE: notesRichTextItem.EmbedObject help

Did you try embedding another file type such as an excel file or text file with the same code? Same behavior?

Subject: RE: notesRichTextItem.EmbedObject help

Yes, tried it with a text file, and entered the file contents rather that the file itself.

Is this the behaviour of when an item is embedded rather than attached? The same happens when i try either option.

Subject: notesRichTextItem.EmbedObject help

Hi i understand ur requirment.

Below i gave sample code.i tested and its working.please match this with ur requirement.

            Dim session As New NotesSession

Dim doc As NotesDocument

Dim rtitem As NotesRichTextItem

Dim object As NotesEmbeddedObject

Dim handle As Variant



Set doc = New NotesDocument( session.CurrentDatabase )

Set rtitem = New NotesRichTextItem( doc, "Body" )



Set object = rtitem.EmbedObject _

( EMBED_ATTACHMENT, "", "d:\test.pdf")

doc.Form = "test"

Call doc.Save( True, True )

Set handle = object.Activate( False )

If ( handle Is Nothing ) Then

	doc.Subject = "This object has no OLE automation interface"

Else

	doc.Subject = "This object has an OLE automation interface"

End If

Call doc.Save( True, True )

Looking forward for ur reply.

Thanks & regards

Karthik.C

Subject: RE: notesRichTextItem.EmbedObject help

Karthik

I am using your code for my web application but I am getting this error:

Error: Notes error: You are not authorized to perform that operation

Do you have any ideas?

thanks