If I try it as
Set objLink_DB = ObjNotes.GetDatabase(Server, NotesDb) Set objLink_View = objLink_DB.getview(NotesView) Set objLink_Doc = objLink_View.getdocumentbykey(NotesKey, True) If Not (objLink_Doc Is Nothing) Then Call rtItem. AppendDocLink(objLink_Doc, "Test") End Ifit generates the message:
Automation Error: The server threw an error
Probably the error is that the RTitem doesn't exist. Before you append a document link, you need to create the Rich Text item. I don't know if you have created your newDoc to send the e-mail, but you'll need to include code like the following to create the Rich Text field body in your e-mail message.
' create outgoing mail message document Set objLink_newDoc = New NotesDocument( objLink_DB ) 'create the body field in the new message document Set rtitem = New NotesRichTextItem (objLink_newDoc, "Body" ) 'then append the doc link (your code) If Not (objLink_Doc Is Nothing) Then Call rtItem. AppendDocLink(objLink_Doc, "Test") 'you could also use the documents subject field as in 'Call rtItem.AppendDocLink (objLink_Doc, objLink_Doc.Subject( 0 ) ) End If 'just in case you need samples of the other mail fields objLink_newDoc.Subject = "Here is a link to the database" objLink_newDoc.SendTo = "Lauri Nodwell" objLink_newDoc.Send( False )
Do you have comments on this Ask the Expert Q&A? Let us know.
This was first published in February 2004