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?
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 )