NoTificatiON E-MaiL fRoM WeB

Monday, March 17, 2008

Notification e-mail will be send out once the form has been submitted from web.

Call from WebQuerySave in Form:
@Command([ToolsRunMacro]; "lscrpt_WebSubmit")

Agent: lscrpt_WebSubmit
Trigger : On Event
Agent List Selection
Programming Language : Lotus Script

Sub Initialize

Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim doc_memo As NotesDocument
Dim content As NotesRichTextItem

Set db = session.currentdatabase

' get dbname and path
Dim tmpPath As String
tmpPath = db.filepath
Do While Instr(tmpPath,"\") > 0
tmpPath = Left$(tmpPath, Instr(tmpPath,"\")-1) + "/" + Right$(tmpPath,Len(tmpPath)-Instr(tmpPath,"\"))
Loop

' check and see if there are any embedded spaces and replace them with +
Do While Instr(tmpPath," ") > 0
tmpPath = Left$(tmpPath, Instr(tmpPath," ")-1) + "+" + Right$(tmpPath,Len(tmpPath)-Instr(tmpPath," "))
Loop

DbName = tmpPath

' end get dbname and path
On Error Goto standarderror
Set doc = session.DocumentContext

doc.datesubmitted = Now

Manager = doc.Manager(0)
TLeader = doc.TLeader(0)

If TLeader = "" Or TLeader = "None" Then
Mail_Sendto = Manager
Else
Mail_Sendto = TLeader
End If

Dim MgrNextApprover ( 0 To 1) As String
MgrNextApprover(0) = Manager
MgrNextApprover(1) = TLeader


doc.ManagementApproval = Fulltrim(MgrNextApprover)
doc.Approver = Mail_Sendto
doc.submitflag = "1"
doc.saveoptions = "1"
docid$ = doc.UniversalID

Manager = doc.Manager(0)

' Notify Manager or Team Leader
On Error Goto Mailerror

Set doc_memo = New NotesDocument (db)
doc_memo.Form = "Memo"
doc_memo.sendto = Mail_sendto

doc_memo.Subject = "Overtime submitted for " & doc.Emp(0)
content1$ = "Overtime for " & Emp & " requires your approval"

Set content = New Notesrichtextitem(doc_memo,"Body")

Call content.AddNewLine ( 1 )
Call content.AppendText ( content1$ )
Call content.AddNewLine ( 2 )
Call content.AppendText ("Please click on the following doclink to pre-approve the request. ")
Call content.AppendDocLink (doc, "")
Call content.AddNewLine ( 2 )
Call content.AppendText ( content2$ )
Call content.AddNewLine ( 2 )
Call content.AppendText ("Thank you.")

Call doc_memo.Send (False)

Goto viewlinks

StandardError: ??

Mailerror: ??

ViewLinks:

End Sub

0 comments: