Lotus Notes, Agent - installation / distrubtion of a agent into mail db

Posted on 2014-11-25
Last Modified: 2014-12-02
Hi Guys!

I need some help with figuring out how to distribute a agent to our users.

We have limited designer/admin rights, but do have rights to create a agent in the mail db.

I have create and agent and want to install / distribute it to users without they need to copy paste the code it self.

Is there any possibility for this?

My dream scenario would be:

The agent is put into its own database, which will be distributed. create a button in that which will copy the agent into the mail database, just like if you would do in the View -> Agents, right click on the agent and copy, and paste it into the mail database..

is this possible?
Question by:Hakum
LVL 46

Expert Comment

by:Sjef Bosman
ID: 40464160
What type of agent is it? Will it be used once, or regularly? Should it stay there, in the mail database? And how about updating the agent, did you think about that?

Anyway, the server can do this for you. Normally, and I don't really like it either but it's the best way, you'd modify the mail template and add the agent in the template. When the Designer task runs (which is normally at night, unless you disabled it), it distributes the updates to every mail database. No need for manual updates.

Suggested procedure:
- make a Notes copy of the mail template you use (mail85.ntf or so), e.g. to mail85x.ntf
- give the template a different template name (see the Properties tab)
- add your agent
- change the template name of your own mail database to the new name, and refresh its design
- check whether the agent is added

Of course, this only works when you are the Admin for the server, you have the Designer client, and you also have sufficient rights to modify the design of a database. If that's not you, I suggest you ask someone who has these requirements. If it's really that important that every user should have the agent, you need the support of your manager.

If you're on your own, forget it. IMHO doing it all by yourself is bound to fail.

Author Comment

ID: 40464304
Thank you for your feed back Sjef!

This would be the way it should be done and this is the correct way i agree! sadly the rights are limited on the database.
The admin has down prioritized this case for over 2 years now... for such a simple addition that would make life easier for tons of people.. but sadly its bureaucracy that is holding the changes back. the administration are centralized but we are allowed to make changes for 1 territory , but they will implement when they feel the need or when they have "time" (this is how we see in from a users point of view).

that said, all i'm looking for is a way to copy an agent from one database to another, a simple code that would do so... i have googled it alot but sadly i found something which i'm not fully understanding... thats why this post to maybe find a alternative..

this is the code i found:
set view=dbSource.Getview("ViewName")
set doc=dbSource.GetdocumentByUnid
call doc.CopytoDatabase(dbDestination)

Open in new window

This is the source (i'm note sure if its allowed to link to other websites, so sorry in advance):

I know its possible to copy documents from 1 database to another so why not a agent?
LVL 30

Expert Comment

ID: 40464318
I wonder, and sjef may be able to answer this, if you do not have the permission rights to modify the design template, will you agent run in that db?

When you create the agent the current user ID will be used to sign the agent, and this needs to have appropriate permissions in the ACL to run.

So you may be able to create the agent and save it in the db, but it will simply fail to execute due to security restrictions. As agents are very powerful I would expect that to be the case if admin are keen to keep things "tidy".

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.


Author Comment

ID: 40464335
Additional info:

It's a agent that do a mail merge from a excel file into a stationary from the mail template. Yes, it should stay there.

this is the code:


%Include "lsconst.lss"



Sub Initialize
	'Mail merge script 
	Dim ws As NotesUIWorkspace
	Set ws = New NotesUIWorkspace
	Dim sendTypes(1) As String
	Dim sendValue As String
	Dim errorCount As Integer
	errorCount = 0
	sendTypes(0) = "Draft messages without sending"
	sendTypes(1) = "Send messages"
	sendValue = ws.Prompt(PROMPT_OKCANCELLIST, "Sending options", "What would you like to do?", "", sendTypes)
	If (sendValue = "") Then
		Exit Sub
	End If
	Dim fileName As String
	Dim strXLFilename As String
	'Prompt for the filename - should be a Microsoft Excel file with columns, where the first row of each column
	'is a token that will be used when replacing text in the body of the message
	'Special tokens: [to], [cc], [subject] set the appropriate fields
	'Make sure the first column does not have any blank cells
	fileName$ = ws.Prompt(12, "Select file", "3")
	If fileName$ = "" Then
		Exit Sub   'Cancel was pressed
	End If
	strXLFilename = fileName$
	Dim s As New NotesSession
	Dim uidoc As NotesUIDocument
	Dim partno As String
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim doc As NotesDocument
	Dim collection As NotesDocumentCollection
	Dim memo As NotesDocument
	Dim body As NotesRichTextItem
	Dim newBody As NotesRichTextItem
	Dim range As NotesRichTextRange
	Dim count As Integer
	Set db = s.CurrentDatabase
	Set collection = db.UnprocessedDocuments
	Set memo = collection.getFirstDocument()
	Dim varXLFile As Variant
	'Get data from the spreadsheet
	Set varXLFile = CreateObject("Excel.Application")
	varXLFile.Visible = False
	Dim varXLWorkbook As Variant
	Set varXLWorkbook = Nothing
	varXLFile.Workbooks.Open strXLFilename
	Set varXLWorkbook = varXLFile.ActiveWorkbook
	Dim varXLSheet As Variant
	Set varXLSheet = varXLWorkbook.ActiveSheet
	Dim lngRow As Integer
	Dim columnNo As Integer
	Dim token As String
	Dim value As String
	lngRow = 2
	Dim maildoc As NotesDocument
	While (Not (varXLSheet.Cells(lngRow, 1).Value = ""))
		'Fill in the template
		Dim subject As String
		subject = memo.Subject(0)
		Set body = memo.GetFirstItem("Body")
		'Compose message
		Set maildoc = New NotesDocument(db)
		Set maildoc= db.CreateDocument()
		maildoc.Form = "Memo"
		maildoc.Subject = subject
		Set newBody = maildoc.CreateRichTextItem("Body")
		Call newBody.appendRTItem(body)
		Set range = newBody.CreateRange			
		'Count the number of fields
		'Look up tokens from the column headings and replace them
		columnNo = 1
		While Not(varXLSheet.Cells(1, columnNo).Value = "")
			token = varXLSheet.Cells(1, columnNo).Value
			value = varXLSheet.Cells(lngRow, columnNo).Value
			count = range.FindAndReplace(token, value, 16)
			If (token = "[to]") Then
				maildoc.SendTo = value
			End If
			If (token = "[cc]") Then
				maildoc.CopyTo = Split(value, ",")
			End If
			If (token = "[subject]") Then
				maildoc.Subject = value
			End If
			columnNo = columnNo + 1
		On Error GoTo save
		If (sendValue = sendTypes(0)) Then
			Call maildoc.Save(True, False)
			maildoc.SaveMessageOnSend = True
			maildoc.PostedDate = Now()
			Call maildoc.Send(False)
			Call maildoc.Save(True, True)
		End If
		GoTo nextrow
		MessageBox("Error processing " + maildoc.sendTo)
		errorCount = errorCount + 1
		Resume Next
		lngRow = lngRow + 1
	If (sendValue = sendTypes(0)) Then
		MsgBox "Drafted " & (lngRow - errorCount - 2) & " message(s). Errors: " & errorCount
		MsgBox "Sent " & (lngRow - errorCount - 2) & " message(s). Errors: " & errorCount
	End If
	Call varXLFile.Quit
End Sub

Open in new window

LVL 46

Accepted Solution

Sjef Bosman earned 500 total points
ID: 40464568
Three ways...

A. the proper way, as described above
Kick some ass here and there, for if your invention would improve the world dramatically there should be someone to back you up in the company.

B. the manual way: by mail
Send a mail to all users, with the code, describing how to enter the code as an agent. I assume everyone has the right to create personal agents, otherwise this will fail (absolutely right there, Kapt). By letting the users enter their own agents, you'll avoid the rights issue (that you don't have the rights to add documents or run an agent in someone else's database).

C. the stuff-em-all way: move your code to Excel!
Rewrite your code to run in Excel VBA. The code could be almost identical, for the better part at least. You'd have to do a different initialisation phase, and the rest is virtually the same. Advantages: no rights problem, no admins involved, easily distributed in the Excel file. Disadvantage: everyone can fiddle with the code...

Expert Comment

by:Fredrik Norling
ID: 40465451

If the users doesn't have access to the database you will not be able to add a agent to the users database.

the general ways to do this is
1. copy the agent to the database using a button inside an email
2. Add the code inside an email in a button and act on all documents inside i.e a folder
3. Add the agent into another database that you distribute and the users add locally on their notes client.
and this database has design that can act on the documents in the users mail database

Author Comment

ID: 40466310
Thank you guys!

@Sjef - I totally understand you point and i'm kinda running my head into the wall here... so i'm open for alternatives like your suggestion C, i have tried to look at some posibilites to rewrite the code i have into vba, although my vba is really rusty almost equal to none existing, so if any of you have some guidance or earlier posts that solves the need please advise.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
IBM Enterprise Integrator - ZID File 1 175
Only send email if contains "abcd" 3 148
IBM Lotus notes 9 101
See used databases in Domino 8 104
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question