Send Email - Lotusscript Help

Hi all,

I have a form, that when completed is sent to a manager and director of the company. For this I have used the @Mailsend formula behind a button which then sends the email to the specified users with a link to the document.

The only problem with this is that its pretty much hardcoded and I need to make this configurable by putting it into the config section that I have created on another form. The reason being that if the director leaves for instance, then I can easily go into the config and replace the user with another.

I am new to notes so I would really apeciate help in how to go about doing this.

I have noticed that Script Libaries section there is a SharedLotusScript bit and I have found some lotusscript called SendEmailRT which is the following code…


Public Sub SendEmailRT(sendto As Variant, cc As Variant, Subject As String, body As NotesRichTextItem, foottext As String,DocToLinkTo As notesdocument,incdoclink As Boolean)

On Error Goto errorhandler

Dim s As New notessession

Dim db As notesdatabase

Set db = s.currentdatabase

Dim memo As New notesdocument(db)



Call memo.ReplaceItemValue("Form","Memo")

Call memo.ReplaceItemValue("SendTo",sendto)

Call memo.ReplaceItemValue("CopyTo",cc)

Call memo.ReplaceItemValue("Subject",subject)

Dim rtitem As New notesrichtextitem(memo,"Body")

Call rtitem.AppendText("Call Logged:          " & doctolinkto.GetItemValueDateTimeArray("DateOpened")(0).localtime)

Call rtitem.AddNewline(1)

Call rtitem.AppendText("Call Ref:                   " & doctolinkto.callref(0))

Call rtitem.AddNewline(1)

Call rtitem.AppendText("Priority:                   " & doctolinkto.priority(0))

Call rtitem.AddNewline(1)

Call rtitem.AppendText("Problem Type:      " & doctolinkto.Category(0) &  " > " & doctolinkto.SubCategory(0))

Call rtitem.AddNewline(1)

Call rtitem.AppendText("Problem:                  " & doctolinkto.ProblemDescription(0))

Call rtitem.AddNewline(1)

Call rtitem.AppendText("__________________________________________________________________________")

Call rtitem.AddNewline(2)

Call rtitem.Appendrtitem(body)

Call rtitem.AddNewline(2)

Call rtitem.appendtext(foottext)

Call rtitem.AddNewline(2)



If incdoclink Then

	Call rtitem.AppendText("Click to view call >>>  ")

	Call rtitem.AppendDocLink(doctolinkto,"Click to view call")

End If

Call memo.Send(False)



Exit Sub

errorhandler:

Call DisplayErrMsg("SharedLotusScript", "SendEmailRT ", Err, _

Error, Erl, ""	)

Resume Next

End Sub


Also I found another section called SendCallEmail with the following code: -


Public Sub SendCallEmail(sendto As Variant, cc As Variant, Subject As String, _

bodytext As String, calldoc As notesdocument, incdoclink As Boolean, _

inclastactiontext As Boolean, incstrapline1 As Boolean)

On Error Goto errorhandler

Dim s As New notessession

Dim db As notesdatabase

Set db = s.currentdatabase

Dim memo As New notesdocument(db)

Call memo.ReplaceItemValue("Form","Memo")



Select Case Typename(sendto)

Case "STRING"

	If sendto = "" Then

		Call memo.ReplaceItemValue("SendTo",cc)	

	Else

		Call memo.ReplaceItemValue("SendTo",sendto)

		Call memo.ReplaceItemValue("CopyTo",cc)

	End If

Case "STRING( )"

	If sendto(0) = "" Then

		Call memo.ReplaceItemValue("SendTo",cc)	

	Else

		Call memo.ReplaceItemValue("SendTo",sendto)

		Call memo.ReplaceItemValue("CopyTo",cc)

	End If

End Select



Call memo.ReplaceItemValue("Subject",subject)

Call memo.ReplaceItemValue("Form","Memo")

Dim rtitem As New notesrichtextitem(memo,"Body")

Call rtitem.AppendText("Call Logged:          " & calldoc.GetItemValueDateTimeArray("DateOpened")(0).localtime)

Call rtitem.AddNewline(1)

Call rtitem.AppendText("Call Ref:                   " & calldoc.callref(0))

Call rtitem.AddNewline(1)

Call rtitem.AppendText("Problem Type:      " & calldoc.Category(0) &  " > " & calldoc.SubCategory(0))

Call rtitem.AddNewline(1)

Call rtitem.AppendText("Priority:      	             " & calldoc.priority(0))

Call rtitem.AddNewline(1)

Call rtitem.AppendText("Problem:                  " & calldoc.ProblemDescription(0))

Call rtitem.AddNewline(1)

Call rtitem.AppendText("__________________________________________________________________________")

Call rtitem.AddNewline(2)

Call rtitem.AppendText(bodytext)

Call rtitem.AddNewline(2)



If incstrapline1 Then

	Call rtitem.AppendText("Please quote the reference number above when contacting IT about this call.")

	Call rtitem.AddNewline(2)		

	Call rtitem.AppendText("With Thanks,")

	Call rtitem.AddNewline(1)

	Call rtitem.AppendText("IT Department")

	Call rtitem.AddNewline(4)

End If



If inclastactiontext Then

	Dim view As notesview

	Set view = db.GetView("va_sabcbmr")

	Dim ve As NotesViewEntry

	Set ve= view.GetEntryByKey(calldoc.UniversalID,True)

	Call rtitem.AppendText("--------Last Call Action-----------")

	If Not(ve Is Nothing) Then

		Call rtitem.AddNewline(1)

		Call rtitem.AppendText(ve.ColumnValues(2))

	End If

	Call rtitem.AddNewline(1)

	Call rtitem.AppendText("----------------------------------------")

	Call rtitem.AddNewline(2)

End If



If incdoclink Then

	If Not(calldoc Is Nothing) Then

		Call rtitem.AppendText("Click to view call >>>  ")

		Call rtitem.AppendDocLink(calldoc,"Click to view call")

		Call rtitem.AddNewline(2)

	End If

End If





If memo.GetItemValue("SendTo")(0) <> "" Then

	Call memo.Send(False)

End If





Exit Sub

errorhandler:

Call DisplayErrMsg("SharedLotusScript", "SendCallEmail", Err, _

Error, Erl, ""	)

Resume Next

End Sub


Am I able to make use of this? If so, how would I incorporate this into making sending emails more configurable???

Thanking you in advance

Subject: Send Email - Lotusscript Help

It sounds like to me Formula will still work in your situation. Have you thought about a simple @DBLookup to a keyword document(s) to dynamically put a recipient(s)?

Subject: RE: Send Email - Lotusscript Help

Hi.

Ok I’ll give this a go thanks