How do you use AppendDocLink when trying to send an email from VB/VBA?

How do you use AppendDocLink when trying to send an e-mail from VB/VBA?

If I try it as

        Set objLink_DB = 
ObjNotes.GetDatabase(Server, NotesDb)
        Set objLink_View = 
        Set objLink_Doc = 
objLink_View.getdocumentbykey(NotesKey, True)

        If Not (objLink_Doc Is Nothing) 
            Call rtItem.
AppendDocLink(objLink_Doc, "Test")
        End If
it 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)
            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.

Dig Deeper on Lotus Notes Domino Application Development

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...