Script should send emails to a group of id whenever I want.

Asked By 0 points N/A Posted on -

I need a script for Lotus notes. That script should send emails to a group of id whenever I want.

It should also add new contracts with that group. Whenever I set to send emails this script should get ready my template to send. Is that possible in Lotus?

Answered By 10 points N/A #125981

Script should send emails to a group of id whenever I want.


Here is a script which is adapted from one of the solutions I have used previously. I have not tested it after writing, so please be cautious while using it. Please make sure that the code is placed in a “Before mail arrives” agent. Also, as this type of agent runs on the server, therefore the c:reports directory must exist on the server which is running on a Windows machine.

As I have not tested the code, I am not sure about the behavior of the code if the file having the same name is already available in the server. It might overwrite the existing file, do not download the new file that is disable overwriting or the system might even crash. So, you have to be really careful while actually placing the script on the server. I have included some additional logging lines in the following code which can prove to be helpful in debugging it.

Sub Initialize
Dim sess As New NotesSession
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim aList As String
Dim objName As String
Dim agentLog As New NotesLog("Agent log")
Call agentLog.OpenAgentLog
Call agentLog.LogAction("Starting DetachAll")
Set doc = sess.DocumentContext
aList = ""
With doc
' ***** Detach from Body field
Set rtitem = .GetFirstItem("Body")
If (rtitem.Type = RICHTEXT) Then
Forall o In rtitem.EmbeddedObjects
objName = o.Source
Call agentLog.LogAction("Detaching " & objName)
Call o.ExtractFile("c:reportsobjName")
If aList = "" Then
aList = objName
aList = aList & ", " & objName
End If
End If
End Forall
End If
End With 'doc
If aList <> "" Then
Call agentLog.LogAction("Detached: " & aList)
Dim newDoc As New NotesDocument(sess.CurrentDatabase)
With newDoc
.Form = "Memo"
.Subject = "New Detachment"
Dim body As New NotesRichTextItem(newDoc, "Body")
Call body.AppendText("At least one attachment (" & aList & ") was detached into c:reports on the server.")
Call .Send(False, "Pradip Sinha/Pantaloon")
End With 'newDoc
End If
Call agentLog.LogAction("Closing Agent Log")
Call agentLog.Close
End Sub

Login/Register to Answer

Related Questions