Subject: href in lotusscript problem
This should do what you want with a few modifications. Just don’t ask my why there is a T on the end of the subroutine for building the e-mail… I can’t remember. The values of interest to you for the web would be the variable strLink which contains the url in the field in the format which is simply http://blah.blah.com. Appending text in this format should create an html link.
If you have the url in a field it’s simply
rtitem.appendText(doc.docURL(0)) (this is in an agent. Any method that builds a valid url will work). What does your URL string look like?
Sub Click(Source As Button)
'Create an e-mail and send the contents of the rtfTestDBLinks field and txtTestDBLinks fields to the person(s) listed in kwdRequestedBy
'Create a log field and update it with the date and time each link was sent to the client.
Dim s As New notessession
Dim doc As NotesDocument
Dim wk As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim db As NotesDatabase
Dim xdoc As notesdocument
Dim body As notesrichtextitem
Dim item As notesitem
Dim logitem As notesitem
Dim txtlinks() As String
Dim v As Variant
Dim copyfieldtomemo As Variant
Dim msubject As String
Dim mbody As String
Dim server As String
Dim replica As String
Dim flag As Variant
Dim x As Integer
Dim counter As Integer
Dim strlinks As String
Dim ldb As notesdatabase
Set db = s.CurrentDatabase
Set uidoc = wk.CurrentDocument
Set doc = uidoc.Document
v = doc.kwdrequestedby
msubject$ = "Project test databases: " + doc.txtProjectTitle(0)
Set item = doc.GetFirstItem("txtTestdblinks")
Set logitem = doc.GetFirstItem("log")
x = 0
counter = 0
'Add the link found in txtTestDBLinks to the body field along with any text
Dim rtitem As Variant
Dim dlink As NotesRichTextDoclink
Dim rtnav As NotesRichTextNavigator
Dim rtrange As NotesRichTextRange
Set rtitem = doc.GetFirstItem("rtfTestDBLinks")
If rtitem.type = RICHTEXT Then
Set rtnav = rtitem.createnavigator
Set dlink = rtnav.GetFirstElement(RTELEM_TYPE_DOCLINK)
If (dlink Is Nothing) Then
Messagebox "No database links in Body item",, "No links"
Set rtitem = Nothing
Set ldb = Nothing
Exit Sub
Else
copyfieldtomemo = True
firstline = True
Set xdoc = New NotesDocument( db )
Set body = New NotesRichTextItem(xdoc, "body")
xdoc.Form = "Memo"
xdoc.SendTo = v
'xdoc.sendto = "Joel Phelan"
xdoc.subject = msubject
Redim Preserve txtlinks(20) As String
If Not (item Is Nothing) Then
Forall a In item.values
txtlinks(x) = a
x = x + 1
End Forall
End If
x = x - 1
Redim Preserve txtlinks(0 To x) As String
counter = 0
While Not(dlink Is Nothing)
If dlink.ServerHint = "" Then
server$ = "Local"
Else
server$ = dlink.ServerHint
End If
replica$ = dlink.DBReplicaID
'Msgbox replica$
Set ldb = New NotesDatabase("", "")
flag = ldb.OpenByReplicaID( server$, replica$ )
If flag = True Then
If Not ldb.IsOpen Then
Msgbox "Database could not be opened."
Exit Sub
End If
Else
Msgbox "No database found"
Exit Sub
End If
’ txtlinks should be an array of strings so that there is an equivalency between notes links and web links.
’ Make sure that there are as many lines as there are links or you’ll go out of bounds.
If counter = x Then
strlinks$ = txtlinks(counter)
Else
strlinks$ = ""
End If
Call buildemailnotificationT(ldb, msubject$, strlinks$, v, copyfieldtomemo, firstline, xdoc, body)
’ Set ldb = Nothing 'To make sure the next link attempt runs in the loop
firstline = False
counter = counter + 1
Set dlink = rtnav.GetNextElement(RTELEM_TYPE_DOCLINK)
Wend
Call xdoc.Send( False )
'Update the log field here
Call logitem.AppendToTextList("Sent notification " + Cstr(Now))
Call doc.Save(True, False)
End If
End If
End Sub
Sub BuildEmailNotificationT(db As NotesDatabase, msubject As String, mbody As String, v As Variant, copyfieldtomemo As Variant, firstline As Variant, xdoc As NotesDocument, body As NotesRichTextItem)
'Write an e-mail
If copyfieldtomemo = True Then
If (Not firstline) Then
Call body.AppendText(lineconst)
Call body.AddNewline(1)
End If
Call body.AppendText("Notes Link - ")
Call body.AppendDocLink( db, db.Title )
Call body.AddNewline(2)
If mbody <> "" Then
Call body.AppendText("Web Links - " & mbody)
End If
Call body.AddNewline(2)
End If
End Sub