Ask the Expert

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: