Domino Code Fragment

Code Name*
MailStuff Library
Date*
06/30/1999
Source (or email address if you prefer)*
Don Bechtold (beck@eki-consulting.com)
IP address:.3.21.76.0
Description*
Type*
LotusScript
Categories*
Implementation:
None (plug and play)
Required Client:
4.5
Server:
4.5
Limitations:
will only work if user name can be found in in-use address books
Comments:
Figures out what mail system is in use for a particular user, and allows current document to be sent from notes client as doclink or URL.

sample use code:
Dim s As New notessession
If GetMailSystem("<username>") = 1 Then
SendDocLink "Don Bechtold", "", "", "Link Test (Stupid)"
Else
senddoclinkasurl "<username>", "", "", _
"Link Test (Please See If It Works)"
End If
Files/Graphics attachments (if applicable): Code:
'MailStuff:
%REM
Copyright (©) 1999 by EKI-Consulting
All Rights Reserved
No Warranty Is Granted
Use At Your Own Risk
%ENDREM

Option Public

Sub SendDocLinkAsURL(st$, ct$, bcc$, subj$)
%REM
Copyright (©) 1999 by EKI-Consulting
All Rights Reserved
No Warranty Is Granted
Use At Your Own Risk

Given the sendto, copyto, blindcarboncopy and subject components
of a mail message, create the message, fill in the appropriate fields
and include the current document as a URL in the body.
%END REM
Dim s As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim sname As notesname
Dim link As notesrichtextitem
Dim ws As New notesuiworkspace
Dim uid As notesuidocument

Set uid = ws.currentdocument
Set db = s.currentdatabase
Set doc = db.createdocument

doc.Form = "Memo"
doc.SendTo = st$
doc.CopyTo = ct$
doc.BlindCopyTo = bcc$
doc.Subject = subj$

'format the filepath for the web
doc.filepath = db.filepath
evl$ = |@replacesubstring(filepath; "\\"; "/")|
eval = Evaluate(evl$, doc)
dbname$ = eval(0)
' get rid of needless item
Call doc.removeitem("filepath")

' get the server component
Set sname = New notesname(db.server)

lt$ = "http://"
lt$ = lt$ & sname.common & "/"
lt$ = lt$ & dbname$ & "/"
lt$ = lt$ & db.replicaid & "/"
lt$ = lt$ & uid.document.universalid
lt$ = lt$ & "?opendocument"
lt$ = Lcase(lt$)

Set link = doc.createrichtextitem("Body")
Call link.appendtext(lt$)
Call doc.send(False)
End Sub
Sub AddDoclinkAsURL(doc)
%REM
Copyright (©) 1999 by EKI-Consulting
All Rights Reserved
No Warranty Is Granted
Use At Your Own Risk

Given an existing document that is created elsewhere, adds the current
document as a URL to the body field and sends it
%END REM

Dim s As New notessession
Dim db As notesdatabase
Dim sname As notesname
Dim link As notesrichtextitem
Dim ws As New notesuiworkspace
Dim uid As notesuidocument

Set uid = ws.currentdocument

Set db = s.currentdatabase

'format the database name component for the web
doc.filepath = db.filepath
evl$ = |@replacesubstring(filepath; "\\"; "/")|
eval = Evaluate(evl$, doc)
dbname$ = eval(0)
' get rid of needless item
Call doc.removeitem("filepath")

'get the server component
Set sname = New notesname(db.server)

lt$ = "http://"
lt$ = lt$ & sname.common & "/"
lt$ = lt$ & dbname$ & "/"
lt$ = lt$ & db.replicaid & "/"
lt$ = lt$ & uid.document.universalid
lt$ = lt$ & "?opendocument"
lt$ = Lcase(lt$)

If doc.hasitem("Body") Then
Set link = doc.getfirstitem("Body")
Else
Set link = doc.createrichtextitem("Body")
End If
Call link.appendtext(lt$)
Call doc.send(False)
End Sub
Sub SendDocLink(st$, ct$, bcc$, subj$)
%REM
Copyright (©) 1999 by EKI-Consulting
All Rights Reserved
No Warranty Is Granted
Use At Your Own Risk

Given the sendto, copyto, blindcarboncopy and subject components
of a mail message, create the message, fill in the appropriate fields
and include the current document as a doclink in the body.
%END REM
Dim s As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim link As notesrichtextitem
Dim ws As New notesuiworkspace
Dim uid As notesuidocument

Set uid = ws.currentdocument
Set db = s.currentdatabase
Set doc = db.createdocument

doc.Form = "Memo"
doc.SendTo = st$
doc.CopyTo = ct$
doc.BlindCopyTo = bcc$
doc.Subject = subj$

Set link = doc.createrichtextitem("Body")
Call link.appenddoclink(uid.document, "")
Call doc.send(False)
End Sub
Function GetMailSystem(ma$) As Integer
%REM
Copyright (©) 1999 by EKI-Consulting
All Rights Reserved
No Warranty Is Granted
Use At Your Own Risk

Given the users name, figures out the mail system in use.
%END REM

Dim s As New notessession
Dim db As notesdatabase
Dim v As notesview
Dim d As notesdocument
getmailsystem = 0
Forall ab In s.addressbooks
Set db = ab
Call db.open("", "")
Set v = db.getview("($Users)")
Set d = v.getdocumentbykey(ma$)
If Not (d Is Nothing) Then
GetMailSystem = Cint(d.MailSystem(0))
Exit Forall
End If
End Forall
End Function