Saturday, April 12, 2008

Using LotusScript, how to get Lotus notes mail file's owner name

Below script helps you to get mail file owner name in IBM Lotus Notes client.

Sub Click(Source As Button)
Dim session As New notesSession
Dim db As NotesDatabase
Dim doc As notesdocument
Dim owner As NotesItem
Dim ownerName As String

Set db = session.CurrentDatabase
Set doc= db.GetProfileDocument("CalendarProfile")
Set owner= doc.getFirstItem("Owner")
Dim userName As New NotesName(owner.Text)
ownerName = userName.Abbreviated
Msgbox "Mail file owner is " & ownerName
End Sub

4 comments:

rupa said...

i hav an application that should not run on web..It should work only on the client. How can it be done??? Can it be done with formula?? if not is there any lotus script code to do thi????

rupa said...

i hav an application that should not run on web..It should work only on the client. How can it be done??? Can it be done with formula?? if not is there any lotus script code to do thi????

Unknown said...

Thanks, it helped alot to set the SendTo-field of current doc to Mailfile-owner:

Sub Click(Source As Button)
Dim session As New notesSession
Dim db As NotesDatabase
Dim doc As notesdocument
Dim owner As NotesItem
Dim ownerName As String

Set db = session.CurrentDatabase
Set doc= Set ownerDoc = db.GetProfileDocument("CalendarProfile")
If Not (ownerDoc Is Nothing) then
Set owner = ownerDoc.getFirstItem("Owner")
Call newDoc.Appenditemvalue("SendTo", owner.Text )
Call newDoc.send(true)
End Sub

Unknown said...

Thanks Piyush & Peter. In my case, the Owner item was not present! I used db.GetProfileDocCollection("CalendarProfile") and looped through each doc till I got Owner item.