LS Email agent

We have a custom help desk system in Notes and we’ve created a dummy mail database called Helpdesk. When you email the helpdesk group all of the IT folks get a copy along with the HelpDesk dummy account. An agent in that mail database creates a document in the helpdesk database and sends out a response email. Nothing too fancy but it works for us. My question is, can I somehow make the agent so that it only works when the email was actually sent to Helpdesk and not CC’d? Right now when we respond to a new ticket we usually CC the Helpdesk group so multiple tickets end up getting created.

Subject: LS Email agent

check the doc.SendTo v the doc.CopyTo fields.raphael

Subject: LS Email agent

Well - it all depends on the agent. Does the agent run on new and modified, or does it run based on inbox folder? Is the agent lotusscript or formula?

Subject: RE: LS Email agent

The agent is in LS and yes it’s running on new and modified documents. That kind of screws me right there, doesn’t it?

Subject: RE: LS Email agent

not really, just check for the form used. as long as the e-mails are all internal to your Notes domain then a reply will have used the “Reply” form vs. the “Memo” form for new (and forwarded) e-mails.

Subject: RE: LS Email agent

So since it’s really just used internally we could get away with just adding a document selection and setting the form to equal “memo”?

Subject: RE: LS Email agent

Not really - it just means you will need to write the exception into the script. Raphael had it right as to the field you want to trigger off of.

The easiest way (without seeing the script) would be to create an if/then statement with a goto to end script if the copyto is there and matches - ie:

If doc.copyto(0) = “CN=HelpDesk/O=mydomain” then

goto endthisscript

end if

endthisscript:

end sub

(make sure the goto tag is just before the “end sub”)

Now this is a very simple fix - depending on the script and if other messages received have contents in the CC field, this may not work, but it is a direction to follow in getting around the messages you do not want duplicated.

If you include the script, I can possibly post a specific fix for it.

Subject: RE: LS Email agent

Thanks I’d really appreciate it. I’m kinda new to LS and prefer to use Formula language whenever possible. Had to use LS for this one though so I fought my way through it the best I could. Here’s the code:

Sub Initialize

Dim session As New notessession

Dim odb As notesdatabase

Set odb = session.currentdatabase

Dim memocollection As notesdocumentcollection

Set memocollection = odb.unprocesseddocuments 

Dim memo As notesdocument

Set memo = memocollection.getfirstdocument	

Dim db As notesdatabase

Set db = New notesdatabase(odb.server, "apps\HelpDesk") 	

Dim view As notesview		

Dim numdoc As notesdocument

Dim doc As notesdocument	

Dim email As NotesDocument	

Do Until memo Is Nothing	

	Set view = db.GetView( "TNumView")

	Set numdoc = view.GetLastDocument		

	Set doc = db.createdocument

	Dim itembody As notesitem

	Dim itemfrom As String

	Dim itemsub As String

	Dim itemNum As Long		

	Dim rtItem As NotesRichTextItem		

	Set itembody= memo.getfirstitem("Body")

	Call itembody.copyitemtodocument(doc, "Description")

	itemfrom = memo.From(0)

	doc.ReqUser = itemfrom

	itemsub = memo.Subject(0)

	doc.type = itemsub

	itemNum = numdoc.TickNum(0) + 1

	doc.TickNum = itemNum

	doc.form = "Ticket"

	doc.status = "New"

	doc.CreatedBy = "Email"

	Call doc.save(True, True)

	Call session.updateprocesseddoc(memo)

	Set memo = memocollection.getnextdocument(memo)

	Set email = New NotesDocument(odb)

	email.form = "memo"	

	email.sendto = doc.ReqUser

	email.subject = "HelpDesk Request Received, Ticket #" & itemnum & " Issued"

	Set rtitem = New notesrichtextitem(email, "Body")

	Call rtitem.AddNewLine(1)

	Call rtitem.AppendText("The HelpDesk has received your request for assistance and a ticket has been opened.")

	Call rtitem.AddNewline(1)

	Call rtitem.AppendText("If you have any questions or additional information concerning your ticket please email")

	Call rtitem.AddNewline(1)

	Call rtitem.AppendText("******")

	Call email.Send(False)

Loop

End Sub

Subject: RE: LS Email agent

Hi Michael,

So this is done as a loop - slight difference from originally described but not by much - and you could do the same process with the form as mentioned by Paul. The script below should do:

Sub Initialize

Dim session As New notessession

Dim odb As notesdatabase

Set odb = session.currentdatabase

Dim memocollection As notesdocumentcollection

Set memocollection = odb.unprocesseddocuments

Dim memo As notesdocument

Set memo = memocollection.getfirstdocument

Dim db As notesdatabase

Set db = New notesdatabase(odb.server, “apps\HelpDesk”)

Dim view As notesview

Dim numdoc As notesdocument

Dim doc As notesdocument

Dim email As NotesDocument

Do Until memo Is Nothing

Set view = db.GetView( “TNumView”)

Set numdoc = view.GetLastDocument

Set doc = db.createdocument

'*here is where we check for documents we do not want to process

'****first option is by form

If doc.form(0) = “Memo” then

'******second option is by CC field

If Not doc.CopyTo(0) = “” then

Dim itembody As notesitem

Dim itemfrom As String

Dim itemsub As String

Dim itemNum As Long

Dim rtItem As NotesRichTextItem

Set itembody= memo.getfirstitem(“Body”)

Call itembody.copyitemtodocument(doc, “Description”)

itemfrom = memo.From(0)

doc.ReqUser = itemfrom

itemsub = memo.Subject(0)

doc.type = itemsub

itemNum = numdoc.TickNum(0) + 1

doc.TickNum = itemNum

doc.form = “Ticket”

doc.status = “New”

doc.CreatedBy = “Email”

Call doc.save(True, True)

Call session.updateprocesseddoc(memo)

Set memo = memocollection.getnextdocument(memo)

Set email = New NotesDocument(odb)

email.form = “memo”

email.sendto = doc.ReqUser

email.subject = “HelpDesk Request Received, Ticket #” & itemnum & " Issued"

Set rtitem = New notesrichtextitem(email, “Body”)

Call rtitem.AddNewLine(1)

Call rtitem.AppendText(“The HelpDesk has received your request for assistance and a ticket has been opened.”)

Call rtitem.AddNewline(1)

Call rtitem.AppendText(“If you have any questions or additional information concerning your ticket please email”)

Call rtitem.AddNewline(1)

Call rtitem.AppendText(“******”)

Call email.Send(False)

'****End of if statement for form & CopyTo

End If

Loop

End Sub

Subject: RE: LS Email agent

great, thanks!